<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/gtest/src/gtest.cc</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/gtest/src</a> - gtest.cc<span style="font-size: 80%;"> (source / <a href="gtest.cc.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">1743</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">338</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2005, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Author: wan@google.com (Zhanyong Wan)
<span class="lineNum">      31 </span>            : //
<span class="lineNum">      32 </span>            : // The Google C++ Testing Framework (Google Test)
<span class="lineNum">      33 </span>            : 
<span class="lineNum">      34 </span>            : #include &quot;gtest/gtest.h&quot;
<span class="lineNum">      35 </span>            : #include &quot;gtest/gtest-spi.h&quot;
<span class="lineNum">      36 </span>            : 
<span class="lineNum">      37 </span>            : #include &lt;ctype.h&gt;
<span class="lineNum">      38 </span>            : #include &lt;math.h&gt;
<span class="lineNum">      39 </span>            : #include &lt;stdarg.h&gt;
<span class="lineNum">      40 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">      41 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      42 </span>            : #include &lt;time.h&gt;
<span class="lineNum">      43 </span>            : #include &lt;wchar.h&gt;
<span class="lineNum">      44 </span>            : #include &lt;wctype.h&gt;
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : #include &lt;algorithm&gt;
<span class="lineNum">      47 </span>            : #include &lt;iomanip&gt;
<span class="lineNum">      48 </span>            : #include &lt;limits&gt;
<span class="lineNum">      49 </span>            : #include &lt;ostream&gt;  // NOLINT
<span class="lineNum">      50 </span>            : #include &lt;sstream&gt;
<span class="lineNum">      51 </span>            : #include &lt;vector&gt;
<span class="lineNum">      52 </span>            : 
<span class="lineNum">      53 </span>            : #if GTEST_OS_LINUX
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            : // TODO(kenton@google.com): Use autoconf to detect availability of
<span class="lineNum">      56 </span>            : // gettimeofday().
<span class="lineNum">      57 </span>            : # define GTEST_HAS_GETTIMEOFDAY_ 1
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : # include &lt;fcntl.h&gt;  // NOLINT
<span class="lineNum">      60 </span>            : # include &lt;limits.h&gt;  // NOLINT
<span class="lineNum">      61 </span>            : # include &lt;sched.h&gt;  // NOLINT
<span class="lineNum">      62 </span>            : // Declares vsnprintf().  This header is not available on Windows.
<span class="lineNum">      63 </span>            : # include &lt;strings.h&gt;  // NOLINT
<span class="lineNum">      64 </span>            : # include &lt;sys/mman.h&gt;  // NOLINT
<span class="lineNum">      65 </span>            : # include &lt;sys/time.h&gt;  // NOLINT
<span class="lineNum">      66 </span>            : # include &lt;unistd.h&gt;  // NOLINT
<span class="lineNum">      67 </span>            : # include &lt;string&gt;
<span class="lineNum">      68 </span>            : 
<span class="lineNum">      69 </span>            : #elif GTEST_OS_SYMBIAN
<span class="lineNum">      70 </span>            : # define GTEST_HAS_GETTIMEOFDAY_ 1
<span class="lineNum">      71 </span>            : # include &lt;sys/time.h&gt;  // NOLINT
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : #elif GTEST_OS_ZOS
<span class="lineNum">      74 </span>            : # define GTEST_HAS_GETTIMEOFDAY_ 1
<span class="lineNum">      75 </span>            : # include &lt;sys/time.h&gt;  // NOLINT
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span>            : // On z/OS we additionally need strings.h for strcasecmp.
<span class="lineNum">      78 </span>            : # include &lt;strings.h&gt;  // NOLINT
<span class="lineNum">      79 </span>            : 
<span class="lineNum">      80 </span>            : #elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            : # include &lt;windows.h&gt;  // NOLINT
<span class="lineNum">      83 </span>            : 
<span class="lineNum">      84 </span>            : #elif GTEST_OS_WINDOWS  // We are on Windows proper.
<span class="lineNum">      85 </span>            : 
<span class="lineNum">      86 </span>            : # include &lt;io.h&gt;  // NOLINT
<span class="lineNum">      87 </span>            : # include &lt;sys/timeb.h&gt;  // NOLINT
<span class="lineNum">      88 </span>            : # include &lt;sys/types.h&gt;  // NOLINT
<span class="lineNum">      89 </span>            : # include &lt;sys/stat.h&gt;  // NOLINT
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            : # if GTEST_OS_WINDOWS_MINGW
<span class="lineNum">      92 </span>            : // MinGW has gettimeofday() but not _ftime64().
<span class="lineNum">      93 </span>            : // TODO(kenton@google.com): Use autoconf to detect availability of
<span class="lineNum">      94 </span>            : //   gettimeofday().
<span class="lineNum">      95 </span>            : // TODO(kenton@google.com): There are other ways to get the time on
<span class="lineNum">      96 </span>            : //   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW
<span class="lineNum">      97 </span>            : //   supports these.  consider using them instead.
<span class="lineNum">      98 </span>            : #  define GTEST_HAS_GETTIMEOFDAY_ 1
<span class="lineNum">      99 </span>            : #  include &lt;sys/time.h&gt;  // NOLINT
<span class="lineNum">     100 </span>            : # endif  // GTEST_OS_WINDOWS_MINGW
<span class="lineNum">     101 </span>            : 
<span class="lineNum">     102 </span>            : // cpplint thinks that the header is already included, so we want to
<span class="lineNum">     103 </span>            : // silence it.
<span class="lineNum">     104 </span>            : # include &lt;windows.h&gt;  // NOLINT
<span class="lineNum">     105 </span>            : 
<span class="lineNum">     106 </span>            : #else
<span class="lineNum">     107 </span>            : 
<span class="lineNum">     108 </span>            : // Assume other platforms have gettimeofday().
<span class="lineNum">     109 </span>            : // TODO(kenton@google.com): Use autoconf to detect availability of
<span class="lineNum">     110 </span>            : //   gettimeofday().
<span class="lineNum">     111 </span>            : # define GTEST_HAS_GETTIMEOFDAY_ 1
<span class="lineNum">     112 </span>            : 
<span class="lineNum">     113 </span>            : // cpplint thinks that the header is already included, so we want to
<span class="lineNum">     114 </span>            : // silence it.
<span class="lineNum">     115 </span>            : # include &lt;sys/time.h&gt;  // NOLINT
<span class="lineNum">     116 </span>            : # include &lt;unistd.h&gt;  // NOLINT
<span class="lineNum">     117 </span>            : 
<span class="lineNum">     118 </span>            : #endif  // GTEST_OS_LINUX
<span class="lineNum">     119 </span>            : 
<span class="lineNum">     120 </span>            : #if GTEST_HAS_EXCEPTIONS
<span class="lineNum">     121 </span>            : # include &lt;stdexcept&gt;
<span class="lineNum">     122 </span>            : #endif
<span class="lineNum">     123 </span>            : 
<span class="lineNum">     124 </span>            : #if GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">     125 </span>            : # include &lt;arpa/inet.h&gt;  // NOLINT
<span class="lineNum">     126 </span>            : # include &lt;netdb.h&gt;  // NOLINT
<span class="lineNum">     127 </span>            : #endif
<span class="lineNum">     128 </span>            : 
<span class="lineNum">     129 </span>            : // Indicates that this translation unit is part of Google Test's
<span class="lineNum">     130 </span>            : // implementation.  It must come before gtest-internal-inl.h is
<span class="lineNum">     131 </span>            : // included, or there will be a compiler error.  This trick is to
<span class="lineNum">     132 </span>            : // prevent a user from accidentally including gtest-internal-inl.h in
<span class="lineNum">     133 </span>            : // his code.
<span class="lineNum">     134 </span>            : #define GTEST_IMPLEMENTATION_ 1
<span class="lineNum">     135 </span>            : #include &quot;src/gtest-internal-inl.h&quot;
<span class="lineNum">     136 </span>            : #undef GTEST_IMPLEMENTATION_
<span class="lineNum">     137 </span>            : 
<span class="lineNum">     138 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">     139 </span>            : # define vsnprintf _vsnprintf
<span class="lineNum">     140 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">     141 </span>            : 
<span class="lineNum">     142 </span>            : namespace testing {
<span class="lineNum">     143 </span>            : 
<span class="lineNum">     144 </span>            : using internal::CountIf;
<span class="lineNum">     145 </span>            : using internal::ForEach;
<span class="lineNum">     146 </span>            : using internal::GetElementOr;
<span class="lineNum">     147 </span>            : using internal::Shuffle;
<span class="lineNum">     148 </span>            : 
<span class="lineNum">     149 </span>            : // Constants.
<span class="lineNum">     150 </span>            : 
<span class="lineNum">     151 </span>            : // A test whose test case name or test name matches this filter is
<span class="lineNum">     152 </span>            : // disabled and not run.
<span class="lineNum">     153 </span>            : static const char kDisableTestFilter[] = &quot;DISABLED_*:*/DISABLED_*&quot;;
<span class="lineNum">     154 </span>            : 
<span class="lineNum">     155 </span>            : // A test case whose name matches this filter is considered a death
<span class="lineNum">     156 </span>            : // test case and will be run before test cases whose name doesn't
<span class="lineNum">     157 </span>            : // match this filter.
<span class="lineNum">     158 </span>            : static const char kDeathTestCaseFilter[] = &quot;*DeathTest:*DeathTest/*&quot;;
<span class="lineNum">     159 </span>            : 
<span class="lineNum">     160 </span>            : // A test filter that matches everything.
<span class="lineNum">     161 </span>            : static const char kUniversalFilter[] = &quot;*&quot;;
<span class="lineNum">     162 </span>            : 
<span class="lineNum">     163 </span>            : // The default output file for XML output.
<span class="lineNum">     164 </span>            : static const char kDefaultOutputFile[] = &quot;test_detail.xml&quot;;
<span class="lineNum">     165 </span>            : 
<span class="lineNum">     166 </span>            : // The environment variable name for the test shard index.
<span class="lineNum">     167 </span>            : static const char kTestShardIndex[] = &quot;GTEST_SHARD_INDEX&quot;;
<span class="lineNum">     168 </span>            : // The environment variable name for the total number of test shards.
<span class="lineNum">     169 </span>            : static const char kTestTotalShards[] = &quot;GTEST_TOTAL_SHARDS&quot;;
<span class="lineNum">     170 </span>            : // The environment variable name for the test shard status file.
<span class="lineNum">     171 </span>            : static const char kTestShardStatusFile[] = &quot;GTEST_SHARD_STATUS_FILE&quot;;
<span class="lineNum">     172 </span>            : 
<span class="lineNum">     173 </span>            : namespace internal {
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span>            : // The text used in failure messages to indicate the start of the
<span class="lineNum">     176 </span>            : // stack trace.
<span class="lineNum">     177 </span>            : const char kStackTraceMarker[] = &quot;\nStack trace:\n&quot;;
<span class="lineNum">     178 </span>            : 
<span class="lineNum">     179 </span>            : // g_help_flag is true iff the --help flag or an equivalent form is
<span class="lineNum">     180 </span>            : // specified on the command line.
<span class="lineNum">     181 </span>            : bool g_help_flag = false;
<span class="lineNum">     182 </span>            : 
<a name="183"><span class="lineNum">     183 </span>            : }  // namespace internal</a>
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span><span class="lineNoCov">          0 : static const char* GetDefaultFilter() {</span>
<span class="lineNum">     186 </span><span class="lineNoCov">          0 :   return kUniversalFilter;</span>
<a name="187"><span class="lineNum">     187 </span>            : }</a>
<span class="lineNum">     188 </span>            : 
<span class="lineNum">     189 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     190 </span>            :     also_run_disabled_tests,
<span class="lineNum">     191 </span>            :     internal::BoolFromGTestEnv(&quot;also_run_disabled_tests&quot;, false),
<span class="lineNum">     192 </span>            :     &quot;Run disabled tests too, in addition to the tests normally being run.&quot;);
<span class="lineNum">     193 </span>            : 
<span class="lineNum">     194 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     195 </span>            :     break_on_failure,
<span class="lineNum">     196 </span>            :     internal::BoolFromGTestEnv(&quot;break_on_failure&quot;, false),
<span class="lineNum">     197 </span>            :     &quot;True iff a failed assertion should be a debugger break-point.&quot;);
<span class="lineNum">     198 </span>            : 
<span class="lineNum">     199 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     200 </span>            :     catch_exceptions,
<span class="lineNum">     201 </span>            :     internal::BoolFromGTestEnv(&quot;catch_exceptions&quot;, true),
<span class="lineNum">     202 </span>            :     &quot;True iff &quot; GTEST_NAME_
<span class="lineNum">     203 </span>            :     &quot; should catch exceptions and treat them as test failures.&quot;);
<span class="lineNum">     204 </span>            : 
<span class="lineNum">     205 </span><span class="lineNoCov">          0 : GTEST_DEFINE_string_(</span>
<span class="lineNum">     206 </span>            :     color,
<span class="lineNum">     207 </span>            :     internal::StringFromGTestEnv(&quot;color&quot;, &quot;auto&quot;),
<span class="lineNum">     208 </span>            :     &quot;Whether to use colors in the output.  Valid values: yes, no, &quot;
<span class="lineNum">     209 </span>            :     &quot;and auto.  'auto' means to use colors if the output is &quot;
<span class="lineNum">     210 </span>            :     &quot;being sent to a terminal and the TERM environment variable &quot;
<span class="lineNum">     211 </span>            :     &quot;is set to a terminal type that supports colors.&quot;);
<span class="lineNum">     212 </span>            : 
<span class="lineNum">     213 </span><span class="lineNoCov">          0 : GTEST_DEFINE_string_(</span>
<span class="lineNum">     214 </span>            :     filter,
<span class="lineNum">     215 </span>            :     internal::StringFromGTestEnv(&quot;filter&quot;, GetDefaultFilter()),
<span class="lineNum">     216 </span>            :     &quot;A colon-separated list of glob (not regex) patterns &quot;
<span class="lineNum">     217 </span>            :     &quot;for filtering the tests to run, optionally followed by a &quot;
<span class="lineNum">     218 </span>            :     &quot;'-' and a : separated list of negative patterns (tests to &quot;
<span class="lineNum">     219 </span>            :     &quot;exclude).  A test is run if it matches one of the positive &quot;
<span class="lineNum">     220 </span>            :     &quot;patterns and does not match any of the negative patterns.&quot;);
<span class="lineNum">     221 </span>            : 
<span class="lineNum">     222 </span>            : GTEST_DEFINE_bool_(list_tests, false,
<span class="lineNum">     223 </span>            :                    &quot;List all tests without running them.&quot;);
<span class="lineNum">     224 </span>            : 
<span class="lineNum">     225 </span><span class="lineNoCov">          0 : GTEST_DEFINE_string_(</span>
<span class="lineNum">     226 </span>            :     output,
<span class="lineNum">     227 </span>            :     internal::StringFromGTestEnv(&quot;output&quot;, &quot;&quot;),
<span class="lineNum">     228 </span>            :     &quot;A format (currently must be \&quot;xml\&quot;), optionally followed &quot;
<span class="lineNum">     229 </span>            :     &quot;by a colon and an output file name or directory. A directory &quot;
<span class="lineNum">     230 </span>            :     &quot;is indicated by a trailing pathname separator. &quot;
<span class="lineNum">     231 </span>            :     &quot;Examples: \&quot;xml:filename.xml\&quot;, \&quot;xml::directoryname/\&quot;. &quot;
<span class="lineNum">     232 </span>            :     &quot;If a directory is specified, output files will be created &quot;
<span class="lineNum">     233 </span>            :     &quot;within that directory, with file-names based on the test &quot;
<span class="lineNum">     234 </span>            :     &quot;executable's name and, if necessary, made unique by adding &quot;
<span class="lineNum">     235 </span>            :     &quot;digits.&quot;);
<span class="lineNum">     236 </span>            : 
<span class="lineNum">     237 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     238 </span>            :     print_time,
<span class="lineNum">     239 </span>            :     internal::BoolFromGTestEnv(&quot;print_time&quot;, true),
<span class="lineNum">     240 </span>            :     &quot;True iff &quot; GTEST_NAME_
<span class="lineNum">     241 </span>            :     &quot; should display elapsed time in text output.&quot;);
<span class="lineNum">     242 </span>            : 
<span class="lineNum">     243 </span><span class="lineNoCov">          0 : GTEST_DEFINE_int32_(</span>
<span class="lineNum">     244 </span>            :     random_seed,
<span class="lineNum">     245 </span>            :     internal::Int32FromGTestEnv(&quot;random_seed&quot;, 0),
<span class="lineNum">     246 </span>            :     &quot;Random number seed to use when shuffling test orders.  Must be in range &quot;
<span class="lineNum">     247 </span>            :     &quot;[1, 99999], or 0 to use a seed based on the current time.&quot;);
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span><span class="lineNoCov">          0 : GTEST_DEFINE_int32_(</span>
<span class="lineNum">     250 </span>            :     repeat,
<span class="lineNum">     251 </span>            :     internal::Int32FromGTestEnv(&quot;repeat&quot;, 1),
<span class="lineNum">     252 </span>            :     &quot;How many times to repeat each test.  Specify a negative number &quot;
<span class="lineNum">     253 </span>            :     &quot;for repeating forever.  Useful for shaking out flaky tests.&quot;);
<span class="lineNum">     254 </span>            : 
<span class="lineNum">     255 </span>            : GTEST_DEFINE_bool_(
<span class="lineNum">     256 </span>            :     show_internal_stack_frames, false,
<span class="lineNum">     257 </span>            :     &quot;True iff &quot; GTEST_NAME_ &quot; should include internal stack frames when &quot;
<span class="lineNum">     258 </span>            :     &quot;printing test failure stack traces.&quot;);
<span class="lineNum">     259 </span>            : 
<span class="lineNum">     260 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     261 </span>            :     shuffle,
<span class="lineNum">     262 </span>            :     internal::BoolFromGTestEnv(&quot;shuffle&quot;, false),
<span class="lineNum">     263 </span>            :     &quot;True iff &quot; GTEST_NAME_
<span class="lineNum">     264 </span>            :     &quot; should randomize tests' order on every run.&quot;);
<span class="lineNum">     265 </span>            : 
<span class="lineNum">     266 </span><span class="lineNoCov">          0 : GTEST_DEFINE_int32_(</span>
<span class="lineNum">     267 </span>            :     stack_trace_depth,
<span class="lineNum">     268 </span>            :     internal::Int32FromGTestEnv(&quot;stack_trace_depth&quot;, kMaxStackTraceDepth),
<span class="lineNum">     269 </span>            :     &quot;The maximum number of stack frames to print when an &quot;
<span class="lineNum">     270 </span>            :     &quot;assertion fails.  The valid range is 0 through 100, inclusive.&quot;);
<span class="lineNum">     271 </span>            : 
<span class="lineNum">     272 </span><span class="lineNoCov">          0 : GTEST_DEFINE_string_(</span>
<span class="lineNum">     273 </span>            :     stream_result_to,
<span class="lineNum">     274 </span>            :     internal::StringFromGTestEnv(&quot;stream_result_to&quot;, &quot;&quot;),
<span class="lineNum">     275 </span>            :     &quot;This flag specifies the host name and the port number on which to stream &quot;
<span class="lineNum">     276 </span>            :     &quot;test results. Example: \&quot;localhost:555\&quot;. The flag is effective only on &quot;
<span class="lineNum">     277 </span>            :     &quot;Linux.&quot;);
<span class="lineNum">     278 </span>            : 
<span class="lineNum">     279 </span><span class="lineNoCov">          0 : GTEST_DEFINE_bool_(</span>
<span class="lineNum">     280 </span>            :     throw_on_failure,
<span class="lineNum">     281 </span>            :     internal::BoolFromGTestEnv(&quot;throw_on_failure&quot;, false),
<span class="lineNum">     282 </span>            :     &quot;When this flag is specified, a failed assertion will throw an exception &quot;
<span class="lineNum">     283 </span>            :     &quot;if exceptions are enabled or exit the program with a non-zero code &quot;
<span class="lineNum">     284 </span>            :     &quot;otherwise.&quot;);
<span class="lineNum">     285 </span>            : 
<span class="lineNum">     286 </span>            : namespace internal {
<span class="lineNum">     287 </span>            : 
<span class="lineNum">     288 </span>            : // Generates a random number from [0, range), using a Linear
<a name="289"><span class="lineNum">     289 </span>            : // Congruential Generator (LCG).  Crashes if 'range' is 0 or greater</a>
<span class="lineNum">     290 </span>            : // than kMaxRange.
<span class="lineNum">     291 </span><span class="lineNoCov">          0 : UInt32 Random::Generate(UInt32 range) {</span>
<span class="lineNum">     292 </span>            :   // These constants are the same as are used in glibc's rand(3).
<span class="lineNum">     293 </span><span class="lineNoCov">          0 :   state_ = (1103515245U*state_ + 12345U) % kMaxRange;</span>
<span class="lineNum">     294 </span>            : 
<span class="lineNum">     295 </span><span class="lineNoCov">          0 :   GTEST_CHECK_(range &gt; 0)</span>
<span class="lineNum">     296 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Cannot generate a number in the range [0, 0).&quot;;</span>
<span class="lineNum">     297 </span><span class="lineNoCov">          0 :   GTEST_CHECK_(range &lt;= kMaxRange)</span>
<span class="lineNum">     298 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Generation of a number in [0, &quot; &lt;&lt; range &lt;&lt; &quot;) was requested, &quot;</span>
<span class="lineNum">     299 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;but this can only generate numbers in [0, &quot; &lt;&lt; kMaxRange &lt;&lt; &quot;).&quot;;</span>
<span class="lineNum">     300 </span>            : 
<span class="lineNum">     301 </span>            :   // Converting via modulus introduces a bit of downward bias, but
<span class="lineNum">     302 </span>            :   // it's simple, and a linear congruential generator isn't too good
<span class="lineNum">     303 </span>            :   // to begin with.
<span class="lineNum">     304 </span><span class="lineNoCov">          0 :   return state_ % range;</span>
<span class="lineNum">     305 </span>            : }
<span class="lineNum">     306 </span>            : 
<span class="lineNum">     307 </span>            : // GTestIsInitialized() returns true iff the user has initialized
<span class="lineNum">     308 </span>            : // Google Test.  Useful for catching the user mistake of not initializing
<span class="lineNum">     309 </span>            : // Google Test before calling RUN_ALL_TESTS().
<span class="lineNum">     310 </span>            : //
<span class="lineNum">     311 </span>            : // A user must call testing::InitGoogleTest() to initialize Google
<span class="lineNum">     312 </span>            : // Test.  g_init_gtest_count is set to the number of times
<span class="lineNum">     313 </span>            : // InitGoogleTest() has been called.  We don't protect this variable
<a name="314"><span class="lineNum">     314 </span>            : // under a mutex as it is only accessed in the main thread.</a>
<span class="lineNum">     315 </span>            : GTEST_API_ int g_init_gtest_count = 0;
<span class="lineNum">     316 </span><span class="lineNoCov">          0 : static bool GTestIsInitialized() { return g_init_gtest_count != 0; }</span>
<span class="lineNum">     317 </span>            : 
<span class="lineNum">     318 </span>            : // Iterates over a vector of TestCases, keeping a running sum of the
<a name="319"><span class="lineNum">     319 </span>            : // results of calling a given int-returning method on each.</a>
<span class="lineNum">     320 </span>            : // Returns the sum.
<span class="lineNum">     321 </span><span class="lineNoCov">          0 : static int SumOverTestCaseList(const std::vector&lt;TestCase*&gt;&amp; case_list,</span>
<span class="lineNum">     322 </span>            :                                int (TestCase::*method)() const) {
<span class="lineNum">     323 </span><span class="lineNoCov">          0 :   int sum = 0;</span>
<span class="lineNum">     324 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; case_list.size(); i++) {</span>
<span class="lineNum">     325 </span><span class="lineNoCov">          0 :     sum += (case_list[i]-&gt;*method)();</span>
<span class="lineNum">     326 </span>            :   }
<span class="lineNum">     327 </span><span class="lineNoCov">          0 :   return sum;</span>
<span class="lineNum">     328 </span>            : }
<a name="329"><span class="lineNum">     329 </span>            : </a>
<span class="lineNum">     330 </span>            : // Returns true iff the test case passed.
<span class="lineNum">     331 </span><span class="lineNoCov">          0 : static bool TestCasePassed(const TestCase* test_case) {</span>
<span class="lineNum">     332 </span><span class="lineNoCov">          0 :   return test_case-&gt;should_run() &amp;&amp; test_case-&gt;Passed();</span>
<span class="lineNum">     333 </span>            : }
<a name="334"><span class="lineNum">     334 </span>            : </a>
<span class="lineNum">     335 </span>            : // Returns true iff the test case failed.
<span class="lineNum">     336 </span><span class="lineNoCov">          0 : static bool TestCaseFailed(const TestCase* test_case) {</span>
<span class="lineNum">     337 </span><span class="lineNoCov">          0 :   return test_case-&gt;should_run() &amp;&amp; test_case-&gt;Failed();</span>
<span class="lineNum">     338 </span>            : }
<span class="lineNum">     339 </span>            : 
<a name="340"><span class="lineNum">     340 </span>            : // Returns true iff test_case contains at least one test that should</a>
<span class="lineNum">     341 </span>            : // run.
<span class="lineNum">     342 </span><span class="lineNoCov">          0 : static bool ShouldRunTestCase(const TestCase* test_case) {</span>
<span class="lineNum">     343 </span><span class="lineNoCov">          0 :   return test_case-&gt;should_run();</span>
<span class="lineNum">     344 </span>            : }
<a name="345"><span class="lineNum">     345 </span>            : </a>
<span class="lineNum">     346 </span>            : // AssertHelper constructor.
<span class="lineNum">     347 </span><span class="lineNoCov">          0 : AssertHelper::AssertHelper(TestPartResult::Type type,</span>
<span class="lineNum">     348 </span>            :                            const char* file,
<span class="lineNum">     349 </span>            :                            int line,
<span class="lineNum">     350 </span>            :                            const char* message)
<span class="lineNum">     351 </span><span class="lineNoCov">          0 :     : data_(new AssertHelperData(type, file, line, message)) {</span>
<a name="352"><span class="lineNum">     352 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     353 </span>            : 
<span class="lineNum">     354 </span><span class="lineNoCov">          0 : AssertHelper::~AssertHelper() {</span>
<span class="lineNum">     355 </span><span class="lineNoCov">          0 :   delete data_;</span>
<span class="lineNum">     356 </span><span class="lineNoCov">          0 : }</span>
<a name="357"><span class="lineNum">     357 </span>            : </a>
<span class="lineNum">     358 </span>            : // Message assignment, for assertion streaming support.
<span class="lineNum">     359 </span><span class="lineNoCov">          0 : void AssertHelper::operator=(const Message&amp; message) const {</span>
<span class="lineNum">     360 </span>            :   UnitTest::GetInstance()-&gt;
<span class="lineNum">     361 </span><span class="lineNoCov">          0 :     AddTestPartResult(data_-&gt;type, data_-&gt;file, data_-&gt;line,</span>
<span class="lineNum">     362 </span><span class="lineNoCov">          0 :                       AppendUserMessage(data_-&gt;message, message),</span>
<span class="lineNum">     363 </span>            :                       UnitTest::GetInstance()-&gt;impl()
<span class="lineNum">     364 </span><span class="lineNoCov">          0 :                       -&gt;CurrentOsStackTraceExceptTop(1)</span>
<span class="lineNum">     365 </span>            :                       // Skips the stack frame for this function itself.
<span class="lineNum">     366 </span><span class="lineNoCov">          0 :                       );  // NOLINT</span>
<span class="lineNum">     367 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     368 </span>            : 
<span class="lineNum">     369 </span>            : // Mutex for linked pointers.
<span class="lineNum">     370 </span>            : GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
<span class="lineNum">     371 </span>            : 
<span class="lineNum">     372 </span>            : // Application pathname gotten in InitGoogleTest.
<span class="lineNum">     373 </span><span class="lineNoCov">          0 : std::string g_executable_path;</span>
<span class="lineNum">     374 </span>            : 
<a name="375"><span class="lineNum">     375 </span>            : // Returns the current application's name, removing directory path if that</a>
<span class="lineNum">     376 </span>            : // is present.
<span class="lineNum">     377 </span><span class="lineNoCov">          0 : FilePath GetCurrentExecutableName() {</span>
<span class="lineNum">     378 </span><span class="lineNoCov">          0 :   FilePath result;</span>
<span class="lineNum">     379 </span>            : 
<span class="lineNum">     380 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">     381 </span>            :   result.Set(FilePath(g_executable_path).RemoveExtension(&quot;exe&quot;));
<span class="lineNum">     382 </span>            : #else
<span class="lineNum">     383 </span><span class="lineNoCov">          0 :   result.Set(FilePath(g_executable_path));</span>
<span class="lineNum">     384 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">     385 </span>            : 
<span class="lineNum">     386 </span><span class="lineNoCov">          0 :   return result.RemoveDirectoryName();</span>
<span class="lineNum">     387 </span>            : }
<span class="lineNum">     388 </span>            : 
<span class="lineNum">     389 </span>            : // Functions for processing the gtest_output flag.
<a name="390"><span class="lineNum">     390 </span>            : </a>
<span class="lineNum">     391 </span>            : // Returns the output format, or &quot;&quot; for normal printed output.
<span class="lineNum">     392 </span><span class="lineNoCov">          0 : std::string UnitTestOptions::GetOutputFormat() {</span>
<span class="lineNum">     393 </span><span class="lineNoCov">          0 :   const char* const gtest_output_flag = GTEST_FLAG(output).c_str();</span>
<span class="lineNum">     394 </span><span class="lineNoCov">          0 :   if (gtest_output_flag == NULL) return std::string(&quot;&quot;);</span>
<span class="lineNum">     395 </span>            : 
<span class="lineNum">     396 </span><span class="lineNoCov">          0 :   const char* const colon = strchr(gtest_output_flag, ':');</span>
<span class="lineNum">     397 </span>            :   return (colon == NULL) ?
<span class="lineNum">     398 </span>            :       std::string(gtest_output_flag) :
<span class="lineNum">     399 </span><span class="lineNoCov">          0 :       std::string(gtest_output_flag, colon - gtest_output_flag);</span>
<span class="lineNum">     400 </span>            : }
<span class="lineNum">     401 </span>            : 
<a name="402"><span class="lineNum">     402 </span>            : // Returns the name of the requested output file, or the default if none</a>
<span class="lineNum">     403 </span>            : // was explicitly specified.
<span class="lineNum">     404 </span><span class="lineNoCov">          0 : std::string UnitTestOptions::GetAbsolutePathToOutputFile() {</span>
<span class="lineNum">     405 </span><span class="lineNoCov">          0 :   const char* const gtest_output_flag = GTEST_FLAG(output).c_str();</span>
<span class="lineNum">     406 </span><span class="lineNoCov">          0 :   if (gtest_output_flag == NULL)</span>
<span class="lineNum">     407 </span><span class="lineNoCov">          0 :     return &quot;&quot;;</span>
<span class="lineNum">     408 </span>            : 
<span class="lineNum">     409 </span><span class="lineNoCov">          0 :   const char* const colon = strchr(gtest_output_flag, ':');</span>
<span class="lineNum">     410 </span><span class="lineNoCov">          0 :   if (colon == NULL)</span>
<span class="lineNum">     411 </span><span class="lineNoCov">          0 :     return internal::FilePath::ConcatPaths(</span>
<span class="lineNum">     412 </span>            :         internal::FilePath(
<span class="lineNum">     413 </span>            :             UnitTest::GetInstance()-&gt;original_working_dir()),
<span class="lineNum">     414 </span><span class="lineNoCov">          0 :         internal::FilePath(kDefaultOutputFile)).string();</span>
<span class="lineNum">     415 </span>            : 
<span class="lineNum">     416 </span><span class="lineNoCov">          0 :   internal::FilePath output_name(colon + 1);</span>
<span class="lineNum">     417 </span><span class="lineNoCov">          0 :   if (!output_name.IsAbsolutePath())</span>
<span class="lineNum">     418 </span>            :     // TODO(wan@google.com): on Windows \some\path is not an absolute
<span class="lineNum">     419 </span>            :     // path (as its meaning depends on the current drive), yet the
<span class="lineNum">     420 </span>            :     // following logic for turning it into an absolute path is wrong.
<span class="lineNum">     421 </span>            :     // Fix it.
<span class="lineNum">     422 </span><span class="lineNoCov">          0 :     output_name = internal::FilePath::ConcatPaths(</span>
<span class="lineNum">     423 </span>            :         internal::FilePath(UnitTest::GetInstance()-&gt;original_working_dir()),
<span class="lineNum">     424 </span><span class="lineNoCov">          0 :         internal::FilePath(colon + 1));</span>
<span class="lineNum">     425 </span>            : 
<span class="lineNum">     426 </span><span class="lineNoCov">          0 :   if (!output_name.IsDirectory())</span>
<span class="lineNum">     427 </span><span class="lineNoCov">          0 :     return output_name.string();</span>
<span class="lineNum">     428 </span>            : 
<span class="lineNum">     429 </span>            :   internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
<span class="lineNum">     430 </span><span class="lineNoCov">          0 :       output_name, internal::GetCurrentExecutableName(),</span>
<span class="lineNum">     431 </span><span class="lineNoCov">          0 :       GetOutputFormat().c_str()));</span>
<span class="lineNum">     432 </span><span class="lineNoCov">          0 :   return result.string();</span>
<span class="lineNum">     433 </span>            : }
<span class="lineNum">     434 </span>            : 
<span class="lineNum">     435 </span>            : // Returns true iff the wildcard pattern matches the string.  The
<span class="lineNum">     436 </span>            : // first ':' or '\0' character in pattern marks the end of it.
<span class="lineNum">     437 </span>            : //
<a name="438"><span class="lineNum">     438 </span>            : // This recursive algorithm isn't very efficient, but is clear and</a>
<span class="lineNum">     439 </span>            : // works well enough for matching test names, which are short.
<span class="lineNum">     440 </span><span class="lineNoCov">          0 : bool UnitTestOptions::PatternMatchesString(const char *pattern,</span>
<span class="lineNum">     441 </span>            :                                            const char *str) {
<span class="lineNum">     442 </span><span class="lineNoCov">          0 :   switch (*pattern) {</span>
<span class="lineNum">     443 </span>            :     case '\0':
<span class="lineNum">     444 </span>            :     case ':':  // Either ':' or '\0' marks the end of the pattern.
<span class="lineNum">     445 </span><span class="lineNoCov">          0 :       return *str == '\0';</span>
<span class="lineNum">     446 </span>            :     case '?':  // Matches any single character.
<span class="lineNum">     447 </span><span class="lineNoCov">          0 :       return *str != '\0' &amp;&amp; PatternMatchesString(pattern + 1, str + 1);</span>
<span class="lineNum">     448 </span>            :     case '*':  // Matches any string (possibly empty) of characters.
<span class="lineNum">     449 </span><span class="lineNoCov">          0 :       return (*str != '\0' &amp;&amp; PatternMatchesString(pattern, str + 1)) ||</span>
<span class="lineNum">     450 </span><span class="lineNoCov">          0 :           PatternMatchesString(pattern + 1, str);</span>
<span class="lineNum">     451 </span>            :     default:  // Non-special character.  Matches itself.
<span class="lineNum">     452 </span><span class="lineNoCov">          0 :       return *pattern == *str &amp;&amp;</span>
<span class="lineNum">     453 </span><span class="lineNoCov">          0 :           PatternMatchesString(pattern + 1, str + 1);</span>
<span class="lineNum">     454 </span>            :   }
<a name="455"><span class="lineNum">     455 </span>            : }</a>
<span class="lineNum">     456 </span>            : 
<span class="lineNum">     457 </span><span class="lineNoCov">          0 : bool UnitTestOptions::MatchesFilter(</span>
<span class="lineNum">     458 </span>            :     const std::string&amp; name, const char* filter) {
<span class="lineNum">     459 </span><span class="lineNoCov">          0 :   const char *cur_pattern = filter;</span>
<span class="lineNum">     460 </span><span class="lineNoCov">          0 :   for (;;) {</span>
<span class="lineNum">     461 </span><span class="lineNoCov">          0 :     if (PatternMatchesString(cur_pattern, name.c_str())) {</span>
<span class="lineNum">     462 </span><span class="lineNoCov">          0 :       return true;</span>
<span class="lineNum">     463 </span>            :     }
<span class="lineNum">     464 </span>            : 
<span class="lineNum">     465 </span>            :     // Finds the next pattern in the filter.
<span class="lineNum">     466 </span><span class="lineNoCov">          0 :     cur_pattern = strchr(cur_pattern, ':');</span>
<span class="lineNum">     467 </span>            : 
<span class="lineNum">     468 </span>            :     // Returns if no more pattern can be found.
<span class="lineNum">     469 </span><span class="lineNoCov">          0 :     if (cur_pattern == NULL) {</span>
<span class="lineNum">     470 </span><span class="lineNoCov">          0 :       return false;</span>
<span class="lineNum">     471 </span>            :     }
<span class="lineNum">     472 </span>            : 
<span class="lineNum">     473 </span>            :     // Skips the pattern separater (the ':' character).
<span class="lineNum">     474 </span><span class="lineNoCov">          0 :     cur_pattern++;</span>
<span class="lineNum">     475 </span>            :   }
<span class="lineNum">     476 </span>            : }
<span class="lineNum">     477 </span>            : 
<a name="478"><span class="lineNum">     478 </span>            : // Returns true iff the user-specified filter matches the test case</a>
<span class="lineNum">     479 </span>            : // name and the test name.
<span class="lineNum">     480 </span><span class="lineNoCov">          0 : bool UnitTestOptions::FilterMatchesTest(const std::string &amp;test_case_name,</span>
<span class="lineNum">     481 </span>            :                                         const std::string &amp;test_name) {
<span class="lineNum">     482 </span><span class="lineNoCov">          0 :   const std::string&amp; full_name = test_case_name + &quot;.&quot; + test_name.c_str();</span>
<span class="lineNum">     483 </span>            : 
<span class="lineNum">     484 </span>            :   // Split --gtest_filter at '-', if there is one, to separate into
<span class="lineNum">     485 </span>            :   // positive filter and negative filter portions
<span class="lineNum">     486 </span><span class="lineNoCov">          0 :   const char* const p = GTEST_FLAG(filter).c_str();</span>
<span class="lineNum">     487 </span><span class="lineNoCov">          0 :   const char* const dash = strchr(p, '-');</span>
<span class="lineNum">     488 </span><span class="lineNoCov">          0 :   std::string positive;</span>
<span class="lineNum">     489 </span><span class="lineNoCov">          0 :   std::string negative;</span>
<span class="lineNum">     490 </span><span class="lineNoCov">          0 :   if (dash == NULL) {</span>
<span class="lineNum">     491 </span><span class="lineNoCov">          0 :     positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter</span>
<span class="lineNum">     492 </span><span class="lineNoCov">          0 :     negative = &quot;&quot;;</span>
<span class="lineNum">     493 </span>            :   } else {
<span class="lineNum">     494 </span><span class="lineNoCov">          0 :     positive = std::string(p, dash);   // Everything up to the dash</span>
<span class="lineNum">     495 </span><span class="lineNoCov">          0 :     negative = std::string(dash + 1);  // Everything after the dash</span>
<span class="lineNum">     496 </span><span class="lineNoCov">          0 :     if (positive.empty()) {</span>
<span class="lineNum">     497 </span>            :       // Treat '-test1' as the same as '*-test1'
<span class="lineNum">     498 </span><span class="lineNoCov">          0 :       positive = kUniversalFilter;</span>
<span class="lineNum">     499 </span>            :     }
<span class="lineNum">     500 </span>            :   }
<span class="lineNum">     501 </span>            : 
<span class="lineNum">     502 </span>            :   // A filter is a colon-separated list of patterns.  It matches a
<span class="lineNum">     503 </span>            :   // test if any pattern in it matches the test.
<span class="lineNum">     504 </span><span class="lineNoCov">          0 :   return (MatchesFilter(full_name, positive.c_str()) &amp;&amp;</span>
<span class="lineNum">     505 </span><span class="lineNoCov">          0 :           !MatchesFilter(full_name, negative.c_str()));</span>
<span class="lineNum">     506 </span>            : }
<span class="lineNum">     507 </span>            : 
<span class="lineNum">     508 </span>            : #if GTEST_HAS_SEH
<span class="lineNum">     509 </span>            : // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
<span class="lineNum">     510 </span>            : // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
<span class="lineNum">     511 </span>            : // This function is useful as an __except condition.
<span class="lineNum">     512 </span>            : int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
<span class="lineNum">     513 </span>            :   // Google Test should handle a SEH exception if:
<span class="lineNum">     514 </span>            :   //   1. the user wants it to, AND
<span class="lineNum">     515 </span>            :   //   2. this is not a breakpoint exception, AND
<span class="lineNum">     516 </span>            :   //   3. this is not a C++ exception (VC++ implements them via SEH,
<span class="lineNum">     517 </span>            :   //      apparently).
<span class="lineNum">     518 </span>            :   //
<span class="lineNum">     519 </span>            :   // SEH exception code for C++ exceptions.
<span class="lineNum">     520 </span>            :   // (see http://support.microsoft.com/kb/185294 for more information).
<span class="lineNum">     521 </span>            :   const DWORD kCxxExceptionCode = 0xe06d7363;
<span class="lineNum">     522 </span>            : 
<span class="lineNum">     523 </span>            :   bool should_handle = true;
<span class="lineNum">     524 </span>            : 
<span class="lineNum">     525 </span>            :   if (!GTEST_FLAG(catch_exceptions))
<span class="lineNum">     526 </span>            :     should_handle = false;
<span class="lineNum">     527 </span>            :   else if (exception_code == EXCEPTION_BREAKPOINT)
<span class="lineNum">     528 </span>            :     should_handle = false;
<span class="lineNum">     529 </span>            :   else if (exception_code == kCxxExceptionCode)
<span class="lineNum">     530 </span>            :     should_handle = false;
<span class="lineNum">     531 </span>            : 
<span class="lineNum">     532 </span>            :   return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
<span class="lineNum">     533 </span>            : }
<span class="lineNum">     534 </span>            : #endif  // GTEST_HAS_SEH
<span class="lineNum">     535 </span>            : 
<span class="lineNum">     536 </span>            : }  // namespace internal
<span class="lineNum">     537 </span>            : 
<span class="lineNum">     538 </span>            : // The c'tor sets this object as the test part result reporter used by
<a name="539"><span class="lineNum">     539 </span>            : // Google Test.  The 'result' parameter specifies where to report the</a>
<span class="lineNum">     540 </span>            : // results. Intercepts only failures from the current thread.
<span class="lineNum">     541 </span><span class="lineNoCov">          0 : ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(</span>
<span class="lineNum">     542 </span>            :     TestPartResultArray* result)
<span class="lineNum">     543 </span>            :     : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
<span class="lineNum">     544 </span><span class="lineNoCov">          0 :       result_(result) {</span>
<span class="lineNum">     545 </span><span class="lineNoCov">          0 :   Init();</span>
<span class="lineNum">     546 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     547 </span>            : 
<span class="lineNum">     548 </span>            : // The c'tor sets this object as the test part result reporter used by
<a name="549"><span class="lineNum">     549 </span>            : // Google Test.  The 'result' parameter specifies where to report the</a>
<span class="lineNum">     550 </span>            : // results.
<span class="lineNum">     551 </span><span class="lineNoCov">          0 : ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(</span>
<span class="lineNum">     552 </span>            :     InterceptMode intercept_mode, TestPartResultArray* result)
<span class="lineNum">     553 </span>            :     : intercept_mode_(intercept_mode),
<span class="lineNum">     554 </span><span class="lineNoCov">          0 :       result_(result) {</span>
<span class="lineNum">     555 </span><span class="lineNoCov">          0 :   Init();</span>
<a name="556"><span class="lineNum">     556 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     557 </span>            : 
<span class="lineNum">     558 </span><span class="lineNoCov">          0 : void ScopedFakeTestPartResultReporter::Init() {</span>
<span class="lineNum">     559 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">     560 </span><span class="lineNoCov">          0 :   if (intercept_mode_ == INTERCEPT_ALL_THREADS) {</span>
<span class="lineNum">     561 </span><span class="lineNoCov">          0 :     old_reporter_ = impl-&gt;GetGlobalTestPartResultReporter();</span>
<span class="lineNum">     562 </span><span class="lineNoCov">          0 :     impl-&gt;SetGlobalTestPartResultReporter(this);</span>
<span class="lineNum">     563 </span>            :   } else {
<span class="lineNum">     564 </span><span class="lineNoCov">          0 :     old_reporter_ = impl-&gt;GetTestPartResultReporterForCurrentThread();</span>
<span class="lineNum">     565 </span><span class="lineNoCov">          0 :     impl-&gt;SetTestPartResultReporterForCurrentThread(this);</span>
<span class="lineNum">     566 </span>            :   }
<span class="lineNum">     567 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     568 </span>            : 
<a name="569"><span class="lineNum">     569 </span>            : // The d'tor restores the test part result reporter used by Google Test</a>
<span class="lineNum">     570 </span>            : // before.
<span class="lineNum">     571 </span><span class="lineNoCov">          0 : ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {</span>
<span class="lineNum">     572 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">     573 </span><span class="lineNoCov">          0 :   if (intercept_mode_ == INTERCEPT_ALL_THREADS) {</span>
<span class="lineNum">     574 </span><span class="lineNoCov">          0 :     impl-&gt;SetGlobalTestPartResultReporter(old_reporter_);</span>
<span class="lineNum">     575 </span>            :   } else {
<span class="lineNum">     576 </span><span class="lineNoCov">          0 :     impl-&gt;SetTestPartResultReporterForCurrentThread(old_reporter_);</span>
<span class="lineNum">     577 </span>            :   }
<span class="lineNum">     578 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     579 </span>            : 
<a name="580"><span class="lineNum">     580 </span>            : // Increments the test part result count and remembers the result.</a>
<span class="lineNum">     581 </span>            : // This method is from the TestPartResultReporterInterface interface.
<span class="lineNum">     582 </span><span class="lineNoCov">          0 : void ScopedFakeTestPartResultReporter::ReportTestPartResult(</span>
<span class="lineNum">     583 </span>            :     const TestPartResult&amp; result) {
<span class="lineNum">     584 </span><span class="lineNoCov">          0 :   result_-&gt;Append(result);</span>
<span class="lineNum">     585 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     586 </span>            : 
<span class="lineNum">     587 </span>            : namespace internal {
<span class="lineNum">     588 </span>            : 
<span class="lineNum">     589 </span>            : // Returns the type ID of ::testing::Test.  We should always call this
<span class="lineNum">     590 </span>            : // instead of GetTypeId&lt; ::testing::Test&gt;() to get the type ID of
<span class="lineNum">     591 </span>            : // testing::Test.  This is to work around a suspected linker bug when
<span class="lineNum">     592 </span>            : // using Google Test as a framework on Mac OS X.  The bug causes
<span class="lineNum">     593 </span>            : // GetTypeId&lt; ::testing::Test&gt;() to return different values depending
<span class="lineNum">     594 </span>            : // on whether the call is from the Google Test framework itself or
<span class="lineNum">     595 </span>            : // from user test code.  GetTestTypeId() is guaranteed to always
<a name="596"><span class="lineNum">     596 </span>            : // return the same value, as it always calls GetTypeId&lt;&gt;() from the</a>
<span class="lineNum">     597 </span>            : // gtest.cc, which is within the Google Test framework.
<span class="lineNum">     598 </span><span class="lineNoCov">          0 : TypeId GetTestTypeId() {</span>
<span class="lineNum">     599 </span><span class="lineNoCov">          0 :   return GetTypeId&lt;Test&gt;();</span>
<span class="lineNum">     600 </span>            : }
<span class="lineNum">     601 </span>            : 
<span class="lineNum">     602 </span>            : // The value of GetTestTypeId() as seen from within the Google Test
<span class="lineNum">     603 </span>            : // library.  This is solely for testing GetTestTypeId().
<span class="lineNum">     604 </span><span class="lineNoCov">          0 : extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();</span>
<span class="lineNum">     605 </span>            : 
<span class="lineNum">     606 </span>            : // This predicate-formatter checks that 'results' contains a test part
<a name="607"><span class="lineNum">     607 </span>            : // failure of the given type and that the failure message contains the</a>
<span class="lineNum">     608 </span>            : // given substring.
<span class="lineNum">     609 </span><span class="lineNoCov">          0 : AssertionResult HasOneFailure(const char* /* results_expr */,</span>
<span class="lineNum">     610 </span>            :                               const char* /* type_expr */,
<span class="lineNum">     611 </span>            :                               const char* /* substr_expr */,
<span class="lineNum">     612 </span>            :                               const TestPartResultArray&amp; results,
<span class="lineNum">     613 </span>            :                               TestPartResult::Type type,
<span class="lineNum">     614 </span>            :                               const string&amp; substr) {
<span class="lineNum">     615 </span>            :   const std::string expected(type == TestPartResult::kFatalFailure ?
<span class="lineNum">     616 </span>            :                         &quot;1 fatal failure&quot; :
<span class="lineNum">     617 </span><span class="lineNoCov">          0 :                         &quot;1 non-fatal failure&quot;);</span>
<span class="lineNum">     618 </span><span class="lineNoCov">          0 :   Message msg;</span>
<span class="lineNum">     619 </span><span class="lineNoCov">          0 :   if (results.size() != 1) {</span>
<span class="lineNum">     620 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;Expected: &quot; &lt;&lt; expected &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">     621 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;  Actual: &quot; &lt;&lt; results.size() &lt;&lt; &quot; failures&quot;;</span>
<span class="lineNum">     622 </span><span class="lineNoCov">          0 :     for (int i = 0; i &lt; results.size(); i++) {</span>
<span class="lineNum">     623 </span><span class="lineNoCov">          0 :       msg &lt;&lt; &quot;\n&quot; &lt;&lt; results.GetTestPartResult(i);</span>
<span class="lineNum">     624 </span>            :     }
<span class="lineNum">     625 </span><span class="lineNoCov">          0 :     return AssertionFailure() &lt;&lt; msg;</span>
<span class="lineNum">     626 </span>            :   }
<span class="lineNum">     627 </span>            : 
<span class="lineNum">     628 </span><span class="lineNoCov">          0 :   const TestPartResult&amp; r = results.GetTestPartResult(0);</span>
<span class="lineNum">     629 </span><span class="lineNoCov">          0 :   if (r.type() != type) {</span>
<span class="lineNum">     630 </span><span class="lineNoCov">          0 :     return AssertionFailure() &lt;&lt; &quot;Expected: &quot; &lt;&lt; expected &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">     631 </span><span class="lineNoCov">          0 :                               &lt;&lt; &quot;  Actual:\n&quot;</span>
<span class="lineNum">     632 </span><span class="lineNoCov">          0 :                               &lt;&lt; r;</span>
<span class="lineNum">     633 </span>            :   }
<span class="lineNum">     634 </span>            : 
<span class="lineNum">     635 </span><span class="lineNoCov">          0 :   if (strstr(r.message(), substr.c_str()) == NULL) {</span>
<span class="lineNum">     636 </span><span class="lineNoCov">          0 :     return AssertionFailure() &lt;&lt; &quot;Expected: &quot; &lt;&lt; expected &lt;&lt; &quot; containing \&quot;&quot;</span>
<span class="lineNum">     637 </span><span class="lineNoCov">          0 :                               &lt;&lt; substr &lt;&lt; &quot;\&quot;\n&quot;</span>
<span class="lineNum">     638 </span><span class="lineNoCov">          0 :                               &lt;&lt; &quot;  Actual:\n&quot;</span>
<span class="lineNum">     639 </span><span class="lineNoCov">          0 :                               &lt;&lt; r;</span>
<span class="lineNum">     640 </span>            :   }
<span class="lineNum">     641 </span>            : 
<span class="lineNum">     642 </span><span class="lineNoCov">          0 :   return AssertionSuccess();</span>
<span class="lineNum">     643 </span>            : }
<span class="lineNum">     644 </span>            : 
<span class="lineNum">     645 </span>            : // The constructor of SingleFailureChecker remembers where to look up
<a name="646"><span class="lineNum">     646 </span>            : // test part results, what type of failure we expect, and what</a>
<span class="lineNum">     647 </span>            : // substring the failure message should contain.
<span class="lineNum">     648 </span><span class="lineNoCov">          0 : SingleFailureChecker:: SingleFailureChecker(</span>
<span class="lineNum">     649 </span>            :     const TestPartResultArray* results,
<span class="lineNum">     650 </span>            :     TestPartResult::Type type,
<span class="lineNum">     651 </span>            :     const string&amp; substr)
<span class="lineNum">     652 </span>            :     : results_(results),
<span class="lineNum">     653 </span>            :       type_(type),
<span class="lineNum">     654 </span><span class="lineNoCov">          0 :       substr_(substr) {}</span>
<span class="lineNum">     655 </span>            : 
<span class="lineNum">     656 </span>            : // The destructor of SingleFailureChecker verifies that the given
<span class="lineNum">     657 </span>            : // TestPartResultArray contains exactly one failure that has the given
<a name="658"><span class="lineNum">     658 </span>            : // type and contains the given substring.  If that's not the case, a</a>
<span class="lineNum">     659 </span>            : // non-fatal failure will be generated.
<span class="lineNum">     660 </span><span class="lineNoCov">          0 : SingleFailureChecker::~SingleFailureChecker() {</span>
<span class="lineNum">     661 </span><span class="lineNoCov">          0 :   EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);</span>
<a name="662"><span class="lineNum">     662 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     663 </span>            : 
<span class="lineNum">     664 </span><span class="lineNoCov">          0 : DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(</span>
<a name="665"><span class="lineNum">     665 </span><span class="lineNoCov">          0 :     UnitTestImpl* unit_test) : unit_test_(unit_test) {}</span></a>
<span class="lineNum">     666 </span>            : 
<span class="lineNum">     667 </span><span class="lineNoCov">          0 : void DefaultGlobalTestPartResultReporter::ReportTestPartResult(</span>
<span class="lineNum">     668 </span>            :     const TestPartResult&amp; result) {
<span class="lineNum">     669 </span><span class="lineNoCov">          0 :   unit_test_-&gt;current_test_result()-&gt;AddTestPartResult(result);</span>
<span class="lineNum">     670 </span><span class="lineNoCov">          0 :   unit_test_-&gt;listeners()-&gt;repeater()-&gt;OnTestPartResult(result);</span>
<a name="671"><span class="lineNum">     671 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     672 </span>            : 
<span class="lineNum">     673 </span><span class="lineNoCov">          0 : DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(</span>
<a name="674"><span class="lineNum">     674 </span><span class="lineNoCov">          0 :     UnitTestImpl* unit_test) : unit_test_(unit_test) {}</span></a>
<span class="lineNum">     675 </span>            : 
<span class="lineNum">     676 </span><span class="lineNoCov">          0 : void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(</span>
<span class="lineNum">     677 </span>            :     const TestPartResult&amp; result) {
<span class="lineNum">     678 </span><span class="lineNoCov">          0 :   unit_test_-&gt;GetGlobalTestPartResultReporter()-&gt;ReportTestPartResult(result);</span>
<span class="lineNum">     679 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     680 </span>            : 
<a name="681"><span class="lineNum">     681 </span>            : // Returns the global test part result reporter.</a>
<span class="lineNum">     682 </span>            : TestPartResultReporterInterface*
<span class="lineNum">     683 </span><span class="lineNoCov">          0 : UnitTestImpl::GetGlobalTestPartResultReporter() {</span>
<span class="lineNum">     684 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;global_test_part_result_reporter_mutex_);</span>
<span class="lineNum">     685 </span><span class="lineNoCov">          0 :   return global_test_part_result_repoter_;</span>
<span class="lineNum">     686 </span>            : }
<a name="687"><span class="lineNum">     687 </span>            : </a>
<span class="lineNum">     688 </span>            : // Sets the global test part result reporter.
<span class="lineNum">     689 </span><span class="lineNoCov">          0 : void UnitTestImpl::SetGlobalTestPartResultReporter(</span>
<span class="lineNum">     690 </span>            :     TestPartResultReporterInterface* reporter) {
<span class="lineNum">     691 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;global_test_part_result_reporter_mutex_);</span>
<span class="lineNum">     692 </span><span class="lineNoCov">          0 :   global_test_part_result_repoter_ = reporter;</span>
<span class="lineNum">     693 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     694 </span>            : 
<a name="695"><span class="lineNum">     695 </span>            : // Returns the test part result reporter for the current thread.</a>
<span class="lineNum">     696 </span>            : TestPartResultReporterInterface*
<span class="lineNum">     697 </span><span class="lineNoCov">          0 : UnitTestImpl::GetTestPartResultReporterForCurrentThread() {</span>
<span class="lineNum">     698 </span><span class="lineNoCov">          0 :   return per_thread_test_part_result_reporter_.get();</span>
<span class="lineNum">     699 </span>            : }
<a name="700"><span class="lineNum">     700 </span>            : </a>
<span class="lineNum">     701 </span>            : // Sets the test part result reporter for the current thread.
<span class="lineNum">     702 </span><span class="lineNoCov">          0 : void UnitTestImpl::SetTestPartResultReporterForCurrentThread(</span>
<span class="lineNum">     703 </span>            :     TestPartResultReporterInterface* reporter) {
<span class="lineNum">     704 </span><span class="lineNoCov">          0 :   per_thread_test_part_result_reporter_.set(reporter);</span>
<span class="lineNum">     705 </span><span class="lineNoCov">          0 : }</span>
<a name="706"><span class="lineNum">     706 </span>            : </a>
<span class="lineNum">     707 </span>            : // Gets the number of successful test cases.
<span class="lineNum">     708 </span><span class="lineNoCov">          0 : int UnitTestImpl::successful_test_case_count() const {</span>
<span class="lineNum">     709 </span><span class="lineNoCov">          0 :   return CountIf(test_cases_, TestCasePassed);</span>
<span class="lineNum">     710 </span>            : }
<a name="711"><span class="lineNum">     711 </span>            : </a>
<span class="lineNum">     712 </span>            : // Gets the number of failed test cases.
<span class="lineNum">     713 </span><span class="lineNoCov">          0 : int UnitTestImpl::failed_test_case_count() const {</span>
<span class="lineNum">     714 </span><span class="lineNoCov">          0 :   return CountIf(test_cases_, TestCaseFailed);</span>
<span class="lineNum">     715 </span>            : }
<a name="716"><span class="lineNum">     716 </span>            : </a>
<span class="lineNum">     717 </span>            : // Gets the number of all test cases.
<span class="lineNum">     718 </span><span class="lineNoCov">          0 : int UnitTestImpl::total_test_case_count() const {</span>
<span class="lineNum">     719 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(test_cases_.size());</span>
<span class="lineNum">     720 </span>            : }
<span class="lineNum">     721 </span>            : 
<a name="722"><span class="lineNum">     722 </span>            : // Gets the number of all test cases that contain at least one test</a>
<span class="lineNum">     723 </span>            : // that should run.
<span class="lineNum">     724 </span><span class="lineNoCov">          0 : int UnitTestImpl::test_case_to_run_count() const {</span>
<span class="lineNum">     725 </span><span class="lineNoCov">          0 :   return CountIf(test_cases_, ShouldRunTestCase);</span>
<span class="lineNum">     726 </span>            : }
<a name="727"><span class="lineNum">     727 </span>            : </a>
<span class="lineNum">     728 </span>            : // Gets the number of successful tests.
<span class="lineNum">     729 </span><span class="lineNoCov">          0 : int UnitTestImpl::successful_test_count() const {</span>
<span class="lineNum">     730 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::successful_test_count);</span>
<span class="lineNum">     731 </span>            : }
<a name="732"><span class="lineNum">     732 </span>            : </a>
<span class="lineNum">     733 </span>            : // Gets the number of failed tests.
<span class="lineNum">     734 </span><span class="lineNoCov">          0 : int UnitTestImpl::failed_test_count() const {</span>
<span class="lineNum">     735 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::failed_test_count);</span>
<span class="lineNum">     736 </span>            : }
<a name="737"><span class="lineNum">     737 </span>            : </a>
<span class="lineNum">     738 </span>            : // Gets the number of disabled tests that will be reported in the XML report.
<span class="lineNum">     739 </span><span class="lineNoCov">          0 : int UnitTestImpl::reportable_disabled_test_count() const {</span>
<span class="lineNum">     740 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_,</span>
<span class="lineNum">     741 </span><span class="lineNoCov">          0 :                              &amp;TestCase::reportable_disabled_test_count);</span>
<span class="lineNum">     742 </span>            : }
<a name="743"><span class="lineNum">     743 </span>            : </a>
<span class="lineNum">     744 </span>            : // Gets the number of disabled tests.
<span class="lineNum">     745 </span><span class="lineNoCov">          0 : int UnitTestImpl::disabled_test_count() const {</span>
<span class="lineNum">     746 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::disabled_test_count);</span>
<span class="lineNum">     747 </span>            : }
<a name="748"><span class="lineNum">     748 </span>            : </a>
<span class="lineNum">     749 </span>            : // Gets the number of tests to be printed in the XML report.
<span class="lineNum">     750 </span><span class="lineNoCov">          0 : int UnitTestImpl::reportable_test_count() const {</span>
<span class="lineNum">     751 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::reportable_test_count);</span>
<span class="lineNum">     752 </span>            : }
<a name="753"><span class="lineNum">     753 </span>            : </a>
<span class="lineNum">     754 </span>            : // Gets the number of all tests.
<span class="lineNum">     755 </span><span class="lineNoCov">          0 : int UnitTestImpl::total_test_count() const {</span>
<span class="lineNum">     756 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::total_test_count);</span>
<span class="lineNum">     757 </span>            : }
<a name="758"><span class="lineNum">     758 </span>            : </a>
<span class="lineNum">     759 </span>            : // Gets the number of tests that should run.
<span class="lineNum">     760 </span><span class="lineNoCov">          0 : int UnitTestImpl::test_to_run_count() const {</span>
<span class="lineNum">     761 </span><span class="lineNoCov">          0 :   return SumOverTestCaseList(test_cases_, &amp;TestCase::test_to_run_count);</span>
<span class="lineNum">     762 </span>            : }
<span class="lineNum">     763 </span>            : 
<span class="lineNum">     764 </span>            : // Returns the current OS stack trace as an std::string.
<span class="lineNum">     765 </span>            : //
<span class="lineNum">     766 </span>            : // The maximum number of stack frames to be included is specified by
<span class="lineNum">     767 </span>            : // the gtest_stack_trace_depth flag.  The skip_count parameter
<span class="lineNum">     768 </span>            : // specifies the number of top frames to be skipped, which doesn't
<span class="lineNum">     769 </span>            : // count against the number of frames to be included.
<span class="lineNum">     770 </span>            : //
<span class="lineNum">     771 </span>            : // For example, if Foo() calls Bar(), which in turn calls
<a name="772"><span class="lineNum">     772 </span>            : // CurrentOsStackTraceExceptTop(1), Foo() will be included in the</a>
<span class="lineNum">     773 </span>            : // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
<span class="lineNum">     774 </span><span class="lineNoCov">          0 : std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {</span>
<span class="lineNum">     775 </span>            :   (void)skip_count;
<span class="lineNum">     776 </span><span class="lineNoCov">          0 :   return &quot;&quot;;</span>
<span class="lineNum">     777 </span>            : }
<a name="778"><span class="lineNum">     778 </span>            : </a>
<span class="lineNum">     779 </span>            : // Returns the current time in milliseconds.
<span class="lineNum">     780 </span><span class="lineNoCov">          0 : TimeInMillis GetTimeInMillis() {</span>
<span class="lineNum">     781 </span>            : #if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
<span class="lineNum">     782 </span>            :   // Difference between 1970-01-01 and 1601-01-01 in milliseconds.
<span class="lineNum">     783 </span>            :   // http://analogous.blogspot.com/2005/04/epoch.html
<span class="lineNum">     784 </span>            :   const TimeInMillis kJavaEpochToWinFileTimeDelta =
<span class="lineNum">     785 </span>            :     static_cast&lt;TimeInMillis&gt;(116444736UL) * 100000UL;
<span class="lineNum">     786 </span>            :   const DWORD kTenthMicrosInMilliSecond = 10000;
<span class="lineNum">     787 </span>            : 
<span class="lineNum">     788 </span>            :   SYSTEMTIME now_systime;
<span class="lineNum">     789 </span>            :   FILETIME now_filetime;
<span class="lineNum">     790 </span>            :   ULARGE_INTEGER now_int64;
<span class="lineNum">     791 </span>            :   // TODO(kenton@google.com): Shouldn't this just use
<span class="lineNum">     792 </span>            :   //   GetSystemTimeAsFileTime()?
<span class="lineNum">     793 </span>            :   GetSystemTime(&amp;now_systime);
<span class="lineNum">     794 </span>            :   if (SystemTimeToFileTime(&amp;now_systime, &amp;now_filetime)) {
<span class="lineNum">     795 </span>            :     now_int64.LowPart = now_filetime.dwLowDateTime;
<span class="lineNum">     796 </span>            :     now_int64.HighPart = now_filetime.dwHighDateTime;
<span class="lineNum">     797 </span>            :     now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
<span class="lineNum">     798 </span>            :       kJavaEpochToWinFileTimeDelta;
<span class="lineNum">     799 </span>            :     return now_int64.QuadPart;
<span class="lineNum">     800 </span>            :   }
<span class="lineNum">     801 </span>            :   return 0;
<span class="lineNum">     802 </span>            : #elif GTEST_OS_WINDOWS &amp;&amp; !GTEST_HAS_GETTIMEOFDAY_
<span class="lineNum">     803 </span>            :   __timeb64 now;
<span class="lineNum">     804 </span>            : 
<span class="lineNum">     805 </span>            : # ifdef _MSC_VER
<span class="lineNum">     806 </span>            : 
<span class="lineNum">     807 </span>            :   // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
<span class="lineNum">     808 </span>            :   // (deprecated function) there.
<span class="lineNum">     809 </span>            :   // TODO(kenton@google.com): Use GetTickCount()?  Or use
<span class="lineNum">     810 </span>            :   //   SystemTimeToFileTime()
<span class="lineNum">     811 </span>            : #  pragma warning(push)          // Saves the current warning state.
<span class="lineNum">     812 </span>            : #  pragma warning(disable:4996)  // Temporarily disables warning 4996.
<span class="lineNum">     813 </span>            :   _ftime64(&amp;now);
<span class="lineNum">     814 </span>            : #  pragma warning(pop)           // Restores the warning state.
<span class="lineNum">     815 </span>            : # else
<span class="lineNum">     816 </span>            : 
<span class="lineNum">     817 </span>            :   _ftime64(&amp;now);
<span class="lineNum">     818 </span>            : 
<span class="lineNum">     819 </span>            : # endif  // _MSC_VER
<span class="lineNum">     820 </span>            : 
<span class="lineNum">     821 </span>            :   return static_cast&lt;TimeInMillis&gt;(now.time) * 1000 + now.millitm;
<span class="lineNum">     822 </span>            : #elif GTEST_HAS_GETTIMEOFDAY_
<span class="lineNum">     823 </span>            :   struct timeval now;
<span class="lineNum">     824 </span><span class="lineNoCov">          0 :   gettimeofday(&amp;now, NULL);</span>
<span class="lineNum">     825 </span><span class="lineNoCov">          0 :   return static_cast&lt;TimeInMillis&gt;(now.tv_sec) * 1000 + now.tv_usec / 1000;</span>
<span class="lineNum">     826 </span>            : #else
<span class="lineNum">     827 </span>            : # error &quot;Don't know how to get the current time on your system.&quot;
<span class="lineNum">     828 </span>            : #endif
<span class="lineNum">     829 </span>            : }
<span class="lineNum">     830 </span>            : 
<span class="lineNum">     831 </span>            : // Utilities
<span class="lineNum">     832 </span>            : 
<span class="lineNum">     833 </span>            : // class String.
<span class="lineNum">     834 </span>            : 
<span class="lineNum">     835 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     836 </span>            : // Creates a UTF-16 wide string from the given ANSI string, allocating
<span class="lineNum">     837 </span>            : // memory using new. The caller is responsible for deleting the return
<span class="lineNum">     838 </span>            : // value using delete[]. Returns the wide string, or NULL if the
<span class="lineNum">     839 </span>            : // input is NULL.
<span class="lineNum">     840 </span>            : LPCWSTR String::AnsiToUtf16(const char* ansi) {
<span class="lineNum">     841 </span>            :   if (!ansi) return NULL;
<span class="lineNum">     842 </span>            :   const int length = strlen(ansi);
<span class="lineNum">     843 </span>            :   const int unicode_length =
<span class="lineNum">     844 </span>            :       MultiByteToWideChar(CP_ACP, 0, ansi, length,
<span class="lineNum">     845 </span>            :                           NULL, 0);
<span class="lineNum">     846 </span>            :   WCHAR* unicode = new WCHAR[unicode_length + 1];
<span class="lineNum">     847 </span>            :   MultiByteToWideChar(CP_ACP, 0, ansi, length,
<span class="lineNum">     848 </span>            :                       unicode, unicode_length);
<span class="lineNum">     849 </span>            :   unicode[unicode_length] = 0;
<span class="lineNum">     850 </span>            :   return unicode;
<span class="lineNum">     851 </span>            : }
<span class="lineNum">     852 </span>            : 
<span class="lineNum">     853 </span>            : // Creates an ANSI string from the given wide string, allocating
<span class="lineNum">     854 </span>            : // memory using new. The caller is responsible for deleting the return
<span class="lineNum">     855 </span>            : // value using delete[]. Returns the ANSI string, or NULL if the
<span class="lineNum">     856 </span>            : // input is NULL.
<span class="lineNum">     857 </span>            : const char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {
<span class="lineNum">     858 </span>            :   if (!utf16_str) return NULL;
<span class="lineNum">     859 </span>            :   const int ansi_length =
<span class="lineNum">     860 </span>            :       WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
<span class="lineNum">     861 </span>            :                           NULL, 0, NULL, NULL);
<span class="lineNum">     862 </span>            :   char* ansi = new char[ansi_length + 1];
<span class="lineNum">     863 </span>            :   WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
<span class="lineNum">     864 </span>            :                       ansi, ansi_length, NULL, NULL);
<span class="lineNum">     865 </span>            :   ansi[ansi_length] = 0;
<span class="lineNum">     866 </span>            :   return ansi;
<span class="lineNum">     867 </span>            : }
<span class="lineNum">     868 </span>            : 
<span class="lineNum">     869 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     870 </span>            : 
<span class="lineNum">     871 </span>            : // Compares two C strings.  Returns true iff they have the same content.
<span class="lineNum">     872 </span>            : //
<span class="lineNum">     873 </span>            : // Unlike strcmp(), this function can handle NULL argument(s).  A NULL
<a name="874"><span class="lineNum">     874 </span>            : // C string is considered different to any non-NULL C string,</a>
<span class="lineNum">     875 </span>            : // including the empty string.
<span class="lineNum">     876 </span><span class="lineNoCov">          0 : bool String::CStringEquals(const char * lhs, const char * rhs) {</span>
<span class="lineNum">     877 </span><span class="lineNoCov">          0 :   if ( lhs == NULL ) return rhs == NULL;</span>
<span class="lineNum">     878 </span>            : 
<span class="lineNum">     879 </span><span class="lineNoCov">          0 :   if ( rhs == NULL ) return false;</span>
<span class="lineNum">     880 </span>            : 
<span class="lineNum">     881 </span><span class="lineNoCov">          0 :   return strcmp(lhs, rhs) == 0;</span>
<span class="lineNum">     882 </span>            : }
<span class="lineNum">     883 </span>            : 
<span class="lineNum">     884 </span>            : #if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     885 </span>            : 
<a name="886"><span class="lineNum">     886 </span>            : // Converts an array of wide chars to a narrow string using the UTF-8</a>
<span class="lineNum">     887 </span>            : // encoding, and streams the result to the given Message object.
<span class="lineNum">     888 </span><span class="lineNoCov">          0 : static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,</span>
<span class="lineNum">     889 </span>            :                                      Message* msg) {
<span class="lineNum">     890 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i != length; ) {  // NOLINT</span>
<span class="lineNum">     891 </span><span class="lineNoCov">          0 :     if (wstr[i] != L'\0') {</span>
<span class="lineNum">     892 </span><span class="lineNoCov">          0 :       *msg &lt;&lt; WideStringToUtf8(wstr + i, static_cast&lt;int&gt;(length - i));</span>
<span class="lineNum">     893 </span><span class="lineNoCov">          0 :       while (i != length &amp;&amp; wstr[i] != L'\0')</span>
<span class="lineNum">     894 </span><span class="lineNoCov">          0 :         i++;</span>
<span class="lineNum">     895 </span>            :     } else {
<span class="lineNum">     896 </span><span class="lineNoCov">          0 :       *msg &lt;&lt; '\0';</span>
<span class="lineNum">     897 </span><span class="lineNoCov">          0 :       i++;</span>
<span class="lineNum">     898 </span>            :     }
<span class="lineNum">     899 </span>            :   }
<span class="lineNum">     900 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     901 </span>            : 
<span class="lineNum">     902 </span>            : #endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     903 </span>            : 
<span class="lineNum">     904 </span>            : }  // namespace internal
<span class="lineNum">     905 </span>            : 
<span class="lineNum">     906 </span>            : // Constructs an empty Message.
<span class="lineNum">     907 </span>            : // We allocate the stringstream separately because otherwise each use of
<span class="lineNum">     908 </span>            : // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
<a name="909"><span class="lineNum">     909 </span>            : // stack frame leading to huge stack frames in some cases; gcc does not reuse</a>
<span class="lineNum">     910 </span>            : // the stack space.
<span class="lineNum">     911 </span><span class="lineNoCov">          0 : Message::Message() : ss_(new ::std::stringstream) {</span>
<span class="lineNum">     912 </span>            :   // By default, we want there to be enough precision when printing
<span class="lineNum">     913 </span>            :   // a double to a Message.
<span class="lineNum">     914 </span><span class="lineNoCov">          0 :   *ss_ &lt;&lt; std::setprecision(std::numeric_limits&lt;double&gt;::digits10 + 2);</span>
<span class="lineNum">     915 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     916 </span>            : 
<a name="917"><span class="lineNum">     917 </span>            : // These two overloads allow streaming a wide C string to a Message</a>
<span class="lineNum">     918 </span>            : // using the UTF-8 encoding.
<span class="lineNum">     919 </span><span class="lineNoCov">          0 : Message&amp; Message::operator &lt;&lt;(const wchar_t* wide_c_str) {</span>
<a name="920"><span class="lineNum">     920 </span><span class="lineNoCov">          0 :   return *this &lt;&lt; internal::String::ShowWideCString(wide_c_str);</span></a>
<span class="lineNum">     921 </span>            : }
<span class="lineNum">     922 </span><span class="lineNoCov">          0 : Message&amp; Message::operator &lt;&lt;(wchar_t* wide_c_str) {</span>
<span class="lineNum">     923 </span><span class="lineNoCov">          0 :   return *this &lt;&lt; internal::String::ShowWideCString(wide_c_str);</span>
<span class="lineNum">     924 </span>            : }
<span class="lineNum">     925 </span>            : 
<span class="lineNum">     926 </span>            : #if GTEST_HAS_STD_WSTRING
<a name="927"><span class="lineNum">     927 </span>            : // Converts the given wide string to a narrow string using the UTF-8</a>
<span class="lineNum">     928 </span>            : // encoding, and streams the result to this Message object.
<span class="lineNum">     929 </span><span class="lineNoCov">          0 : Message&amp; Message::operator &lt;&lt;(const ::std::wstring&amp; wstr) {</span>
<span class="lineNum">     930 </span><span class="lineNoCov">          0 :   internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);</span>
<span class="lineNum">     931 </span><span class="lineNoCov">          0 :   return *this;</span>
<span class="lineNum">     932 </span>            : }
<span class="lineNum">     933 </span>            : #endif  // GTEST_HAS_STD_WSTRING
<span class="lineNum">     934 </span>            : 
<span class="lineNum">     935 </span>            : #if GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     936 </span>            : // Converts the given wide string to a narrow string using the UTF-8
<span class="lineNum">     937 </span>            : // encoding, and streams the result to this Message object.
<span class="lineNum">     938 </span>            : Message&amp; Message::operator &lt;&lt;(const ::wstring&amp; wstr) {
<span class="lineNum">     939 </span>            :   internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
<span class="lineNum">     940 </span>            :   return *this;
<span class="lineNum">     941 </span>            : }
<span class="lineNum">     942 </span>            : #endif  // GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     943 </span>            : 
<a name="944"><span class="lineNum">     944 </span>            : // Gets the text streamed to this object so far as an std::string.</a>
<span class="lineNum">     945 </span>            : // Each '\0' character in the buffer is replaced with &quot;\\0&quot;.
<span class="lineNum">     946 </span><span class="lineNoCov">          0 : std::string Message::GetString() const {</span>
<span class="lineNum">     947 </span><span class="lineNoCov">          0 :   return internal::StringStreamToString(ss_.get());</span>
<span class="lineNum">     948 </span>            : }
<span class="lineNum">     949 </span>            : 
<a name="950"><span class="lineNum">     950 </span>            : // AssertionResult constructors.</a>
<span class="lineNum">     951 </span>            : // Used in EXPECT_TRUE/FALSE(assertion_result).
<span class="lineNum">     952 </span><span class="lineNoCov">          0 : AssertionResult::AssertionResult(const AssertionResult&amp; other)</span>
<span class="lineNum">     953 </span><span class="lineNoCov">          0 :     : success_(other.success_),</span>
<span class="lineNum">     954 </span><span class="lineNoCov">          0 :       message_(other.message_.get() != NULL ?</span>
<span class="lineNum">     955 </span><span class="lineNoCov">          0 :                new ::std::string(*other.message_) :</span>
<span class="lineNum">     956 </span><span class="lineNoCov">          0 :                static_cast&lt; ::std::string*&gt;(NULL)) {</span>
<span class="lineNum">     957 </span><span class="lineNoCov">          0 : }</span>
<a name="958"><span class="lineNum">     958 </span>            : </a>
<span class="lineNum">     959 </span>            : // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
<span class="lineNum">     960 </span><span class="lineNoCov">          0 : AssertionResult AssertionResult::operator!() const {</span>
<span class="lineNum">     961 </span><span class="lineNoCov">          0 :   AssertionResult negation(!success_);</span>
<span class="lineNum">     962 </span><span class="lineNoCov">          0 :   if (message_.get() != NULL)</span>
<span class="lineNum">     963 </span><span class="lineNoCov">          0 :     negation &lt;&lt; *message_;</span>
<span class="lineNum">     964 </span><span class="lineNoCov">          0 :   return negation;</span>
<span class="lineNum">     965 </span>            : }
<a name="966"><span class="lineNum">     966 </span>            : </a>
<span class="lineNum">     967 </span>            : // Makes a successful assertion result.
<span class="lineNum">     968 </span><span class="lineNoCov">          0 : AssertionResult AssertionSuccess() {</span>
<span class="lineNum">     969 </span><span class="lineNoCov">          0 :   return AssertionResult(true);</span>
<span class="lineNum">     970 </span>            : }
<a name="971"><span class="lineNum">     971 </span>            : </a>
<span class="lineNum">     972 </span>            : // Makes a failed assertion result.
<span class="lineNum">     973 </span><span class="lineNoCov">          0 : AssertionResult AssertionFailure() {</span>
<span class="lineNum">     974 </span><span class="lineNoCov">          0 :   return AssertionResult(false);</span>
<span class="lineNum">     975 </span>            : }
<span class="lineNum">     976 </span>            : 
<a name="977"><span class="lineNum">     977 </span>            : // Makes a failed assertion result with the given failure message.</a>
<span class="lineNum">     978 </span>            : // Deprecated; use AssertionFailure() &lt;&lt; message.
<span class="lineNum">     979 </span><span class="lineNoCov">          0 : AssertionResult AssertionFailure(const Message&amp; message) {</span>
<span class="lineNum">     980 </span><span class="lineNoCov">          0 :   return AssertionFailure() &lt;&lt; message;</span>
<span class="lineNum">     981 </span>            : }
<span class="lineNum">     982 </span>            : 
<span class="lineNum">     983 </span>            : namespace internal {
<span class="lineNum">     984 </span>            : 
<span class="lineNum">     985 </span>            : // Constructs and returns the message for an equality assertion
<span class="lineNum">     986 </span>            : // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
<span class="lineNum">     987 </span>            : //
<span class="lineNum">     988 </span>            : // The first four parameters are the expressions used in the assertion
<span class="lineNum">     989 </span>            : // and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
<span class="lineNum">     990 </span>            : // where foo is 5 and bar is 6, we have:
<span class="lineNum">     991 </span>            : //
<span class="lineNum">     992 </span>            : //   expected_expression: &quot;foo&quot;
<span class="lineNum">     993 </span>            : //   actual_expression:   &quot;bar&quot;
<span class="lineNum">     994 </span>            : //   expected_value:      &quot;5&quot;
<span class="lineNum">     995 </span>            : //   actual_value:        &quot;6&quot;
<span class="lineNum">     996 </span>            : //
<span class="lineNum">     997 </span>            : // The ignoring_case parameter is true iff the assertion is a
<a name="998"><span class="lineNum">     998 </span>            : // *_STRCASEEQ*.  When it's true, the string &quot; (ignoring case)&quot; will</a>
<span class="lineNum">     999 </span>            : // be inserted into the message.
<span class="lineNum">    1000 </span><span class="lineNoCov">          0 : AssertionResult EqFailure(const char* expected_expression,</span>
<span class="lineNum">    1001 </span>            :                           const char* actual_expression,
<span class="lineNum">    1002 </span>            :                           const std::string&amp; expected_value,
<span class="lineNum">    1003 </span>            :                           const std::string&amp; actual_value,
<span class="lineNum">    1004 </span>            :                           bool ignoring_case) {
<span class="lineNum">    1005 </span><span class="lineNoCov">          0 :   Message msg;</span>
<span class="lineNum">    1006 </span><span class="lineNoCov">          0 :   msg &lt;&lt; &quot;Value of: &quot; &lt;&lt; actual_expression;</span>
<span class="lineNum">    1007 </span><span class="lineNoCov">          0 :   if (actual_value != actual_expression) {</span>
<span class="lineNum">    1008 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;\n  Actual: &quot; &lt;&lt; actual_value;</span>
<span class="lineNum">    1009 </span>            :   }
<span class="lineNum">    1010 </span>            : 
<span class="lineNum">    1011 </span><span class="lineNoCov">          0 :   msg &lt;&lt; &quot;\nExpected: &quot; &lt;&lt; expected_expression;</span>
<span class="lineNum">    1012 </span><span class="lineNoCov">          0 :   if (ignoring_case) {</span>
<span class="lineNum">    1013 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot; (ignoring case)&quot;;</span>
<span class="lineNum">    1014 </span>            :   }
<span class="lineNum">    1015 </span><span class="lineNoCov">          0 :   if (expected_value != expected_expression) {</span>
<span class="lineNum">    1016 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;\nWhich is: &quot; &lt;&lt; expected_value;</span>
<span class="lineNum">    1017 </span>            :   }
<span class="lineNum">    1018 </span>            : 
<span class="lineNum">    1019 </span><span class="lineNoCov">          0 :   return AssertionFailure() &lt;&lt; msg;</span>
<span class="lineNum">    1020 </span>            : }
<a name="1021"><span class="lineNum">    1021 </span>            : </a>
<span class="lineNum">    1022 </span>            : // Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
<span class="lineNum">    1023 </span><span class="lineNoCov">          0 : std::string GetBoolAssertionFailureMessage(</span>
<span class="lineNum">    1024 </span>            :     const AssertionResult&amp; assertion_result,
<span class="lineNum">    1025 </span>            :     const char* expression_text,
<span class="lineNum">    1026 </span>            :     const char* actual_predicate_value,
<span class="lineNum">    1027 </span>            :     const char* expected_predicate_value) {
<span class="lineNum">    1028 </span><span class="lineNoCov">          0 :   const char* actual_message = assertion_result.message();</span>
<span class="lineNum">    1029 </span><span class="lineNoCov">          0 :   Message msg;</span>
<span class="lineNum">    1030 </span><span class="lineNoCov">          0 :   msg &lt;&lt; &quot;Value of: &quot; &lt;&lt; expression_text</span>
<span class="lineNum">    1031 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;\n  Actual: &quot; &lt;&lt; actual_predicate_value;</span>
<span class="lineNum">    1032 </span><span class="lineNoCov">          0 :   if (actual_message[0] != '\0')</span>
<span class="lineNum">    1033 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot; (&quot; &lt;&lt; actual_message &lt;&lt; &quot;)&quot;;</span>
<span class="lineNum">    1034 </span><span class="lineNoCov">          0 :   msg &lt;&lt; &quot;\nExpected: &quot; &lt;&lt; expected_predicate_value;</span>
<span class="lineNum">    1035 </span><span class="lineNoCov">          0 :   return msg.GetString();</span>
<span class="lineNum">    1036 </span>            : }
<a name="1037"><span class="lineNum">    1037 </span>            : </a>
<span class="lineNum">    1038 </span>            : // Helper function for implementing ASSERT_NEAR.
<span class="lineNum">    1039 </span><span class="lineNoCov">          0 : AssertionResult DoubleNearPredFormat(const char* expr1,</span>
<span class="lineNum">    1040 </span>            :                                      const char* expr2,
<span class="lineNum">    1041 </span>            :                                      const char* abs_error_expr,
<span class="lineNum">    1042 </span>            :                                      double val1,
<span class="lineNum">    1043 </span>            :                                      double val2,
<span class="lineNum">    1044 </span>            :                                      double abs_error) {
<span class="lineNum">    1045 </span><span class="lineNoCov">          0 :   const double diff = fabs(val1 - val2);</span>
<span class="lineNum">    1046 </span><span class="lineNoCov">          0 :   if (diff &lt;= abs_error) return AssertionSuccess();</span>
<span class="lineNum">    1047 </span>            : 
<span class="lineNum">    1048 </span>            :   // TODO(wan): do not print the value of an expression if it's
<span class="lineNum">    1049 </span>            :   // already a literal.
<span class="lineNum">    1050 </span><span class="lineNoCov">          0 :   return AssertionFailure()</span>
<span class="lineNum">    1051 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;The difference between &quot; &lt;&lt; expr1 &lt;&lt; &quot; and &quot; &lt;&lt; expr2</span>
<span class="lineNum">    1052 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot; is &quot; &lt;&lt; diff &lt;&lt; &quot;, which exceeds &quot; &lt;&lt; abs_error_expr &lt;&lt; &quot;, where\n&quot;</span>
<span class="lineNum">    1053 </span><span class="lineNoCov">          0 :       &lt;&lt; expr1 &lt;&lt; &quot; evaluates to &quot; &lt;&lt; val1 &lt;&lt; &quot;,\n&quot;</span>
<span class="lineNum">    1054 </span><span class="lineNoCov">          0 :       &lt;&lt; expr2 &lt;&lt; &quot; evaluates to &quot; &lt;&lt; val2 &lt;&lt; &quot;, and\n&quot;</span>
<span class="lineNum">    1055 </span><span class="lineNoCov">          0 :       &lt;&lt; abs_error_expr &lt;&lt; &quot; evaluates to &quot; &lt;&lt; abs_error &lt;&lt; &quot;.&quot;;</span>
<span class="lineNum">    1056 </span>            : }
<span class="lineNum">    1057 </span>            : 
<span class="lineNum">    1058 </span>            : 
<a name="1059"><span class="lineNum">    1059 </span>            : // Helper template for implementing FloatLE() and DoubleLE().</a>
<span class="lineNum">    1060 </span>            : template &lt;typename RawType&gt;
<span class="lineNum">    1061 </span><span class="lineNoCov">          0 : AssertionResult FloatingPointLE(const char* expr1,</span>
<span class="lineNum">    1062 </span>            :                                 const char* expr2,
<span class="lineNum">    1063 </span>            :                                 RawType val1,
<span class="lineNum">    1064 </span>            :                                 RawType val2) {
<span class="lineNum">    1065 </span>            :   // Returns success if val1 is less than val2,
<span class="lineNum">    1066 </span><span class="lineNoCov">          0 :   if (val1 &lt; val2) {</span>
<span class="lineNum">    1067 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1068 </span>            :   }
<span class="lineNum">    1069 </span>            : 
<span class="lineNum">    1070 </span>            :   // or if val1 is almost equal to val2.
<span class="lineNum">    1071 </span><span class="lineNoCov">          0 :   const FloatingPoint&lt;RawType&gt; lhs(val1), rhs(val2);</span>
<span class="lineNum">    1072 </span><span class="lineNoCov">          0 :   if (lhs.AlmostEquals(rhs)) {</span>
<span class="lineNum">    1073 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1074 </span>            :   }
<span class="lineNum">    1075 </span>            : 
<span class="lineNum">    1076 </span>            :   // Note that the above two checks will both fail if either val1 or
<span class="lineNum">    1077 </span>            :   // val2 is NaN, as the IEEE floating-point standard requires that
<span class="lineNum">    1078 </span>            :   // any predicate involving a NaN must return false.
<span class="lineNum">    1079 </span>            : 
<span class="lineNum">    1080 </span><span class="lineNoCov">          0 :   ::std::stringstream val1_ss;</span>
<span class="lineNum">    1081 </span><span class="lineNoCov">          0 :   val1_ss &lt;&lt; std::setprecision(std::numeric_limits&lt;RawType&gt;::digits10 + 2)</span>
<span class="lineNum">    1082 </span>            :           &lt;&lt; val1;
<span class="lineNum">    1083 </span>            : 
<span class="lineNum">    1084 </span><span class="lineNoCov">          0 :   ::std::stringstream val2_ss;</span>
<span class="lineNum">    1085 </span><span class="lineNoCov">          0 :   val2_ss &lt;&lt; std::setprecision(std::numeric_limits&lt;RawType&gt;::digits10 + 2)</span>
<span class="lineNum">    1086 </span>            :           &lt;&lt; val2;
<span class="lineNum">    1087 </span>            : 
<span class="lineNum">    1088 </span>            :   return AssertionFailure()
<span class="lineNum">    1089 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Expected: (&quot; &lt;&lt; expr1 &lt;&lt; &quot;) &lt;= (&quot; &lt;&lt; expr2 &lt;&lt; &quot;)\n&quot;</span>
<span class="lineNum">    1090 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;  Actual: &quot; &lt;&lt; StringStreamToString(&amp;val1_ss) &lt;&lt; &quot; vs &quot;</span>
<span class="lineNum">    1091 </span><span class="lineNoCov">          0 :       &lt;&lt; StringStreamToString(&amp;val2_ss);</span>
<span class="lineNum">    1092 </span>            : }
<span class="lineNum">    1093 </span>            : 
<span class="lineNum">    1094 </span>            : }  // namespace internal
<span class="lineNum">    1095 </span>            : 
<a name="1096"><span class="lineNum">    1096 </span>            : // Asserts that val1 is less than, or almost equal to, val2.  Fails</a>
<span class="lineNum">    1097 </span>            : // otherwise.  In particular, it fails if either val1 or val2 is NaN.
<span class="lineNum">    1098 </span><span class="lineNoCov">          0 : AssertionResult FloatLE(const char* expr1, const char* expr2,</span>
<span class="lineNum">    1099 </span>            :                         float val1, float val2) {
<span class="lineNum">    1100 </span><span class="lineNoCov">          0 :   return internal::FloatingPointLE&lt;float&gt;(expr1, expr2, val1, val2);</span>
<span class="lineNum">    1101 </span>            : }
<span class="lineNum">    1102 </span>            : 
<a name="1103"><span class="lineNum">    1103 </span>            : // Asserts that val1 is less than, or almost equal to, val2.  Fails</a>
<span class="lineNum">    1104 </span>            : // otherwise.  In particular, it fails if either val1 or val2 is NaN.
<span class="lineNum">    1105 </span><span class="lineNoCov">          0 : AssertionResult DoubleLE(const char* expr1, const char* expr2,</span>
<span class="lineNum">    1106 </span>            :                          double val1, double val2) {
<span class="lineNum">    1107 </span><span class="lineNoCov">          0 :   return internal::FloatingPointLE&lt;double&gt;(expr1, expr2, val1, val2);</span>
<span class="lineNum">    1108 </span>            : }
<span class="lineNum">    1109 </span>            : 
<span class="lineNum">    1110 </span>            : namespace internal {
<span class="lineNum">    1111 </span>            : 
<a name="1112"><span class="lineNum">    1112 </span>            : // The helper function for {ASSERT|EXPECT}_EQ with int or enum</a>
<span class="lineNum">    1113 </span>            : // arguments.
<span class="lineNum">    1114 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperEQ(const char* expected_expression,</span>
<span class="lineNum">    1115 </span>            :                             const char* actual_expression,
<span class="lineNum">    1116 </span>            :                             BiggestInt expected,
<span class="lineNum">    1117 </span>            :                             BiggestInt actual) {
<span class="lineNum">    1118 </span><span class="lineNoCov">          0 :   if (expected == actual) {</span>
<span class="lineNum">    1119 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1120 </span>            :   }
<span class="lineNum">    1121 </span>            : 
<span class="lineNum">    1122 </span>            :   return EqFailure(expected_expression,
<span class="lineNum">    1123 </span>            :                    actual_expression,
<span class="lineNum">    1124 </span><span class="lineNoCov">          0 :                    FormatForComparisonFailureMessage(expected, actual),</span>
<span class="lineNum">    1125 </span><span class="lineNoCov">          0 :                    FormatForComparisonFailureMessage(actual, expected),</span>
<span class="lineNum">    1126 </span><span class="lineNoCov">          0 :                    false);</span>
<span class="lineNum">    1127 </span>            : }
<span class="lineNum">    1128 </span>            : 
<span class="lineNum">    1129 </span>            : // A macro for implementing the helper functions needed to implement
<span class="lineNum">    1130 </span>            : // ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here
<span class="lineNum">    1131 </span>            : // just to avoid copy-and-paste of similar code.
<span class="lineNum">    1132 </span>            : #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
<span class="lineNum">    1133 </span>            : AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
<span class="lineNum">    1134 </span>            :                                    BiggestInt val1, BiggestInt val2) {\
<span class="lineNum">    1135 </span>            :   if (val1 op val2) {\
<span class="lineNum">    1136 </span>            :     return AssertionSuccess();\
<span class="lineNum">    1137 </span>            :   } else {\
<span class="lineNum">    1138 </span>            :     return AssertionFailure() \
<span class="lineNum">    1139 </span>            :         &lt;&lt; &quot;Expected: (&quot; &lt;&lt; expr1 &lt;&lt; &quot;) &quot; #op &quot; (&quot; &lt;&lt; expr2\
<span class="lineNum">    1140 </span>            :         &lt;&lt; &quot;), actual: &quot; &lt;&lt; FormatForComparisonFailureMessage(val1, val2)\
<span class="lineNum">    1141 </span>            :         &lt;&lt; &quot; vs &quot; &lt;&lt; FormatForComparisonFailureMessage(val2, val1);\
<span class="lineNum">    1142 </span>            :   }\
<span class="lineNum">    1143 </span>            : }
<span class="lineNum">    1144 </span>            : 
<a name="1145"><span class="lineNum">    1145 </span>            : // Implements the helper function for {ASSERT|EXPECT}_NE with int or</a>
<span class="lineNum">    1146 </span>            : // enum arguments.
<span class="lineNum">    1147 </span><span class="lineNoCov">          0 : GTEST_IMPL_CMP_HELPER_(NE, !=)</span>
<a name="1148"><span class="lineNum">    1148 </span>            : // Implements the helper function for {ASSERT|EXPECT}_LE with int or</a>
<span class="lineNum">    1149 </span>            : // enum arguments.
<span class="lineNum">    1150 </span><span class="lineNoCov">          0 : GTEST_IMPL_CMP_HELPER_(LE, &lt;=)</span>
<a name="1151"><span class="lineNum">    1151 </span>            : // Implements the helper function for {ASSERT|EXPECT}_LT with int or</a>
<span class="lineNum">    1152 </span>            : // enum arguments.
<span class="lineNum">    1153 </span><span class="lineNoCov">          0 : GTEST_IMPL_CMP_HELPER_(LT, &lt; )</span>
<a name="1154"><span class="lineNum">    1154 </span>            : // Implements the helper function for {ASSERT|EXPECT}_GE with int or</a>
<span class="lineNum">    1155 </span>            : // enum arguments.
<span class="lineNum">    1156 </span><span class="lineNoCov">          0 : GTEST_IMPL_CMP_HELPER_(GE, &gt;=)</span>
<a name="1157"><span class="lineNum">    1157 </span>            : // Implements the helper function for {ASSERT|EXPECT}_GT with int or</a>
<span class="lineNum">    1158 </span>            : // enum arguments.
<span class="lineNum">    1159 </span><span class="lineNoCov">          0 : GTEST_IMPL_CMP_HELPER_(GT, &gt; )</span>
<span class="lineNum">    1160 </span>            : 
<span class="lineNum">    1161 </span>            : #undef GTEST_IMPL_CMP_HELPER_
<a name="1162"><span class="lineNum">    1162 </span>            : </a>
<span class="lineNum">    1163 </span>            : // The helper function for {ASSERT|EXPECT}_STREQ.
<span class="lineNum">    1164 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTREQ(const char* expected_expression,</span>
<span class="lineNum">    1165 </span>            :                                const char* actual_expression,
<span class="lineNum">    1166 </span>            :                                const char* expected,
<span class="lineNum">    1167 </span>            :                                const char* actual) {
<span class="lineNum">    1168 </span><span class="lineNoCov">          0 :   if (String::CStringEquals(expected, actual)) {</span>
<span class="lineNum">    1169 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1170 </span>            :   }
<span class="lineNum">    1171 </span>            : 
<span class="lineNum">    1172 </span>            :   return EqFailure(expected_expression,
<span class="lineNum">    1173 </span>            :                    actual_expression,
<span class="lineNum">    1174 </span><span class="lineNoCov">          0 :                    PrintToString(expected),</span>
<span class="lineNum">    1175 </span><span class="lineNoCov">          0 :                    PrintToString(actual),</span>
<span class="lineNum">    1176 </span><span class="lineNoCov">          0 :                    false);</span>
<span class="lineNum">    1177 </span>            : }
<a name="1178"><span class="lineNum">    1178 </span>            : </a>
<span class="lineNum">    1179 </span>            : // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
<span class="lineNum">    1180 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,</span>
<span class="lineNum">    1181 </span>            :                                    const char* actual_expression,
<span class="lineNum">    1182 </span>            :                                    const char* expected,
<span class="lineNum">    1183 </span>            :                                    const char* actual) {
<span class="lineNum">    1184 </span><span class="lineNoCov">          0 :   if (String::CaseInsensitiveCStringEquals(expected, actual)) {</span>
<span class="lineNum">    1185 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1186 </span>            :   }
<span class="lineNum">    1187 </span>            : 
<span class="lineNum">    1188 </span>            :   return EqFailure(expected_expression,
<span class="lineNum">    1189 </span>            :                    actual_expression,
<span class="lineNum">    1190 </span><span class="lineNoCov">          0 :                    PrintToString(expected),</span>
<span class="lineNum">    1191 </span><span class="lineNoCov">          0 :                    PrintToString(actual),</span>
<span class="lineNum">    1192 </span><span class="lineNoCov">          0 :                    true);</span>
<span class="lineNum">    1193 </span>            : }
<a name="1194"><span class="lineNum">    1194 </span>            : </a>
<span class="lineNum">    1195 </span>            : // The helper function for {ASSERT|EXPECT}_STRNE.
<span class="lineNum">    1196 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTRNE(const char* s1_expression,</span>
<span class="lineNum">    1197 </span>            :                                const char* s2_expression,
<span class="lineNum">    1198 </span>            :                                const char* s1,
<span class="lineNum">    1199 </span>            :                                const char* s2) {
<span class="lineNum">    1200 </span><span class="lineNoCov">          0 :   if (!String::CStringEquals(s1, s2)) {</span>
<span class="lineNum">    1201 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1202 </span>            :   } else {
<span class="lineNum">    1203 </span><span class="lineNoCov">          0 :     return AssertionFailure() &lt;&lt; &quot;Expected: (&quot; &lt;&lt; s1_expression &lt;&lt; &quot;) != (&quot;</span>
<span class="lineNum">    1204 </span><span class="lineNoCov">          0 :                               &lt;&lt; s2_expression &lt;&lt; &quot;), actual: \&quot;&quot;</span>
<span class="lineNum">    1205 </span><span class="lineNoCov">          0 :                               &lt;&lt; s1 &lt;&lt; &quot;\&quot; vs \&quot;&quot; &lt;&lt; s2 &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    1206 </span>            :   }
<span class="lineNum">    1207 </span>            : }
<a name="1208"><span class="lineNum">    1208 </span>            : </a>
<span class="lineNum">    1209 </span>            : // The helper function for {ASSERT|EXPECT}_STRCASENE.
<span class="lineNum">    1210 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTRCASENE(const char* s1_expression,</span>
<span class="lineNum">    1211 </span>            :                                    const char* s2_expression,
<span class="lineNum">    1212 </span>            :                                    const char* s1,
<span class="lineNum">    1213 </span>            :                                    const char* s2) {
<span class="lineNum">    1214 </span><span class="lineNoCov">          0 :   if (!String::CaseInsensitiveCStringEquals(s1, s2)) {</span>
<span class="lineNum">    1215 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1216 </span>            :   } else {
<span class="lineNum">    1217 </span><span class="lineNoCov">          0 :     return AssertionFailure()</span>
<span class="lineNum">    1218 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;Expected: (&quot; &lt;&lt; s1_expression &lt;&lt; &quot;) != (&quot;</span>
<span class="lineNum">    1219 </span><span class="lineNoCov">          0 :         &lt;&lt; s2_expression &lt;&lt; &quot;) (ignoring case), actual: \&quot;&quot;</span>
<span class="lineNum">    1220 </span><span class="lineNoCov">          0 :         &lt;&lt; s1 &lt;&lt; &quot;\&quot; vs \&quot;&quot; &lt;&lt; s2 &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    1221 </span>            :   }
<span class="lineNum">    1222 </span>            : }
<span class="lineNum">    1223 </span>            : 
<span class="lineNum">    1224 </span>            : }  // namespace internal
<span class="lineNum">    1225 </span>            : 
<span class="lineNum">    1226 </span>            : namespace {
<span class="lineNum">    1227 </span>            : 
<span class="lineNum">    1228 </span>            : // Helper functions for implementing IsSubString() and IsNotSubstring().
<span class="lineNum">    1229 </span>            : 
<span class="lineNum">    1230 </span>            : // This group of overloaded functions return true iff needle is a
<span class="lineNum">    1231 </span>            : // substring of haystack.  NULL is considered a substring of itself
<a name="1232"><span class="lineNum">    1232 </span>            : // only.</a>
<span class="lineNum">    1233 </span>            : 
<span class="lineNum">    1234 </span><span class="lineNoCov">          0 : bool IsSubstringPred(const char* needle, const char* haystack) {</span>
<span class="lineNum">    1235 </span><span class="lineNoCov">          0 :   if (needle == NULL || haystack == NULL)</span>
<span class="lineNum">    1236 </span><span class="lineNoCov">          0 :     return needle == haystack;</span>
<span class="lineNum">    1237 </span>            : 
<span class="lineNum">    1238 </span><span class="lineNoCov">          0 :   return strstr(haystack, needle) != NULL;</span>
<a name="1239"><span class="lineNum">    1239 </span>            : }</a>
<span class="lineNum">    1240 </span>            : 
<span class="lineNum">    1241 </span><span class="lineNoCov">          0 : bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {</span>
<span class="lineNum">    1242 </span><span class="lineNoCov">          0 :   if (needle == NULL || haystack == NULL)</span>
<span class="lineNum">    1243 </span><span class="lineNoCov">          0 :     return needle == haystack;</span>
<span class="lineNum">    1244 </span>            : 
<span class="lineNum">    1245 </span><span class="lineNoCov">          0 :   return wcsstr(haystack, needle) != NULL;</span>
<span class="lineNum">    1246 </span>            : }
<span class="lineNum">    1247 </span>            : 
<a name="1248"><span class="lineNum">    1248 </span>            : // StringType here can be either ::std::string or ::std::wstring.</a>
<span class="lineNum">    1249 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1250 </span><span class="lineNoCov">          0 : bool IsSubstringPred(const StringType&amp; needle,</span>
<span class="lineNum">    1251 </span>            :                      const StringType&amp; haystack) {
<span class="lineNum">    1252 </span><span class="lineNoCov">          0 :   return haystack.find(needle) != StringType::npos;</span>
<span class="lineNum">    1253 </span>            : }
<span class="lineNum">    1254 </span>            : 
<span class="lineNum">    1255 </span>            : // This function implements either IsSubstring() or IsNotSubstring(),
<span class="lineNum">    1256 </span>            : // depending on the value of the expected_to_be_substring parameter.
<span class="lineNum">    1257 </span>            : // StringType here can be const char*, const wchar_t*, ::std::string,
<a name="1258"><span class="lineNum">    1258 </span>            : // or ::std::wstring.</a>
<span class="lineNum">    1259 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1260 </span><span class="lineNoCov">          0 : AssertionResult IsSubstringImpl(</span>
<span class="lineNum">    1261 </span>            :     bool expected_to_be_substring,
<span class="lineNum">    1262 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1263 </span>            :     const StringType&amp; needle, const StringType&amp; haystack) {
<span class="lineNum">    1264 </span><span class="lineNoCov">          0 :   if (IsSubstringPred(needle, haystack) == expected_to_be_substring)</span>
<span class="lineNum">    1265 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1266 </span>            : 
<span class="lineNum">    1267 </span><span class="lineNoCov">          0 :   const bool is_wide_string = sizeof(needle[0]) &gt; 1;</span>
<span class="lineNum">    1268 </span><span class="lineNoCov">          0 :   const char* const begin_string_quote = is_wide_string ? &quot;L\&quot;&quot; : &quot;\&quot;&quot;;</span>
<span class="lineNum">    1269 </span>            :   return AssertionFailure()
<span class="lineNum">    1270 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Value of: &quot; &lt;&lt; needle_expr &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">    1271 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;  Actual: &quot; &lt;&lt; begin_string_quote &lt;&lt; needle &lt;&lt; &quot;\&quot;\n&quot;</span>
<span class="lineNum">    1272 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Expected: &quot; &lt;&lt; (expected_to_be_substring ? &quot;&quot; : &quot;not &quot;)</span>
<span class="lineNum">    1273 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;a substring of &quot; &lt;&lt; haystack_expr &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">    1274 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Which is: &quot; &lt;&lt; begin_string_quote &lt;&lt; haystack &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    1275 </span>            : }
<span class="lineNum">    1276 </span>            : 
<span class="lineNum">    1277 </span>            : }  // namespace
<span class="lineNum">    1278 </span>            : 
<span class="lineNum">    1279 </span>            : // IsSubstring() and IsNotSubstring() check whether needle is a
<span class="lineNum">    1280 </span>            : // substring of haystack (NULL is considered a substring of itself
<a name="1281"><span class="lineNum">    1281 </span>            : // only), and return an appropriate error message when they fail.</a>
<span class="lineNum">    1282 </span>            : 
<span class="lineNum">    1283 </span><span class="lineNoCov">          0 : AssertionResult IsSubstring(</span>
<span class="lineNum">    1284 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1285 </span>            :     const char* needle, const char* haystack) {
<span class="lineNum">    1286 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1287"><span class="lineNum">    1287 </span>            : }</a>
<span class="lineNum">    1288 </span>            : 
<span class="lineNum">    1289 </span><span class="lineNoCov">          0 : AssertionResult IsSubstring(</span>
<span class="lineNum">    1290 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1291 </span>            :     const wchar_t* needle, const wchar_t* haystack) {
<span class="lineNum">    1292 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1293"><span class="lineNum">    1293 </span>            : }</a>
<span class="lineNum">    1294 </span>            : 
<span class="lineNum">    1295 </span><span class="lineNoCov">          0 : AssertionResult IsNotSubstring(</span>
<span class="lineNum">    1296 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1297 </span>            :     const char* needle, const char* haystack) {
<span class="lineNum">    1298 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1299"><span class="lineNum">    1299 </span>            : }</a>
<span class="lineNum">    1300 </span>            : 
<span class="lineNum">    1301 </span><span class="lineNoCov">          0 : AssertionResult IsNotSubstring(</span>
<span class="lineNum">    1302 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1303 </span>            :     const wchar_t* needle, const wchar_t* haystack) {
<span class="lineNum">    1304 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1305"><span class="lineNum">    1305 </span>            : }</a>
<span class="lineNum">    1306 </span>            : 
<span class="lineNum">    1307 </span><span class="lineNoCov">          0 : AssertionResult IsSubstring(</span>
<span class="lineNum">    1308 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1309 </span>            :     const ::std::string&amp; needle, const ::std::string&amp; haystack) {
<span class="lineNum">    1310 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1311"><span class="lineNum">    1311 </span>            : }</a>
<span class="lineNum">    1312 </span>            : 
<span class="lineNum">    1313 </span><span class="lineNoCov">          0 : AssertionResult IsNotSubstring(</span>
<span class="lineNum">    1314 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1315 </span>            :     const ::std::string&amp; needle, const ::std::string&amp; haystack) {
<span class="lineNum">    1316 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);</span>
<span class="lineNum">    1317 </span>            : }
<a name="1318"><span class="lineNum">    1318 </span>            : </a>
<span class="lineNum">    1319 </span>            : #if GTEST_HAS_STD_WSTRING
<span class="lineNum">    1320 </span><span class="lineNoCov">          0 : AssertionResult IsSubstring(</span>
<span class="lineNum">    1321 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1322 </span>            :     const ::std::wstring&amp; needle, const ::std::wstring&amp; haystack) {
<span class="lineNum">    1323 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);</span>
<a name="1324"><span class="lineNum">    1324 </span>            : }</a>
<span class="lineNum">    1325 </span>            : 
<span class="lineNum">    1326 </span><span class="lineNoCov">          0 : AssertionResult IsNotSubstring(</span>
<span class="lineNum">    1327 </span>            :     const char* needle_expr, const char* haystack_expr,
<span class="lineNum">    1328 </span>            :     const ::std::wstring&amp; needle, const ::std::wstring&amp; haystack) {
<span class="lineNum">    1329 </span><span class="lineNoCov">          0 :   return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);</span>
<span class="lineNum">    1330 </span>            : }
<span class="lineNum">    1331 </span>            : #endif  // GTEST_HAS_STD_WSTRING
<span class="lineNum">    1332 </span>            : 
<span class="lineNum">    1333 </span>            : namespace internal {
<span class="lineNum">    1334 </span>            : 
<span class="lineNum">    1335 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    1336 </span>            : 
<span class="lineNum">    1337 </span>            : namespace {
<span class="lineNum">    1338 </span>            : 
<span class="lineNum">    1339 </span>            : // Helper function for IsHRESULT{SuccessFailure} predicates
<span class="lineNum">    1340 </span>            : AssertionResult HRESULTFailureHelper(const char* expr,
<span class="lineNum">    1341 </span>            :                                      const char* expected,
<span class="lineNum">    1342 </span>            :                                      long hr) {  // NOLINT
<span class="lineNum">    1343 </span>            : # if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1344 </span>            : 
<span class="lineNum">    1345 </span>            :   // Windows CE doesn't support FormatMessage.
<span class="lineNum">    1346 </span>            :   const char error_text[] = &quot;&quot;;
<span class="lineNum">    1347 </span>            : 
<span class="lineNum">    1348 </span>            : # else
<span class="lineNum">    1349 </span>            : 
<span class="lineNum">    1350 </span>            :   // Looks up the human-readable system message for the HRESULT code
<span class="lineNum">    1351 </span>            :   // and since we're not passing any params to FormatMessage, we don't
<span class="lineNum">    1352 </span>            :   // want inserts expanded.
<span class="lineNum">    1353 </span>            :   const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
<span class="lineNum">    1354 </span>            :                        FORMAT_MESSAGE_IGNORE_INSERTS;
<span class="lineNum">    1355 </span>            :   const DWORD kBufSize = 4096;
<span class="lineNum">    1356 </span>            :   // Gets the system's human readable message string for this HRESULT.
<span class="lineNum">    1357 </span>            :   char error_text[kBufSize] = { '\0' };
<span class="lineNum">    1358 </span>            :   DWORD message_length = ::FormatMessageA(kFlags,
<span class="lineNum">    1359 </span>            :                                           0,  // no source, we're asking system
<span class="lineNum">    1360 </span>            :                                           hr,  // the error
<span class="lineNum">    1361 </span>            :                                           0,  // no line width restrictions
<span class="lineNum">    1362 </span>            :                                           error_text,  // output buffer
<span class="lineNum">    1363 </span>            :                                           kBufSize,  // buf size
<span class="lineNum">    1364 </span>            :                                           NULL);  // no arguments for inserts
<span class="lineNum">    1365 </span>            :   // Trims tailing white space (FormatMessage leaves a trailing CR-LF)
<span class="lineNum">    1366 </span>            :   for (; message_length &amp;&amp; IsSpace(error_text[message_length - 1]);
<span class="lineNum">    1367 </span>            :           --message_length) {
<span class="lineNum">    1368 </span>            :     error_text[message_length - 1] = '\0';
<span class="lineNum">    1369 </span>            :   }
<span class="lineNum">    1370 </span>            : 
<span class="lineNum">    1371 </span>            : # endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1372 </span>            : 
<span class="lineNum">    1373 </span>            :   const std::string error_hex(&quot;0x&quot; + String::FormatHexInt(hr));
<span class="lineNum">    1374 </span>            :   return ::testing::AssertionFailure()
<span class="lineNum">    1375 </span>            :       &lt;&lt; &quot;Expected: &quot; &lt;&lt; expr &lt;&lt; &quot; &quot; &lt;&lt; expected &lt;&lt; &quot;.\n&quot;
<span class="lineNum">    1376 </span>            :       &lt;&lt; &quot;  Actual: &quot; &lt;&lt; error_hex &lt;&lt; &quot; &quot; &lt;&lt; error_text &lt;&lt; &quot;\n&quot;;
<span class="lineNum">    1377 </span>            : }
<span class="lineNum">    1378 </span>            : 
<span class="lineNum">    1379 </span>            : }  // namespace
<span class="lineNum">    1380 </span>            : 
<span class="lineNum">    1381 </span>            : AssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT
<span class="lineNum">    1382 </span>            :   if (SUCCEEDED(hr)) {
<span class="lineNum">    1383 </span>            :     return AssertionSuccess();
<span class="lineNum">    1384 </span>            :   }
<span class="lineNum">    1385 </span>            :   return HRESULTFailureHelper(expr, &quot;succeeds&quot;, hr);
<span class="lineNum">    1386 </span>            : }
<span class="lineNum">    1387 </span>            : 
<span class="lineNum">    1388 </span>            : AssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT
<span class="lineNum">    1389 </span>            :   if (FAILED(hr)) {
<span class="lineNum">    1390 </span>            :     return AssertionSuccess();
<span class="lineNum">    1391 </span>            :   }
<span class="lineNum">    1392 </span>            :   return HRESULTFailureHelper(expr, &quot;fails&quot;, hr);
<span class="lineNum">    1393 </span>            : }
<span class="lineNum">    1394 </span>            : 
<span class="lineNum">    1395 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    1396 </span>            : 
<span class="lineNum">    1397 </span>            : // Utility functions for encoding Unicode text (wide strings) in
<span class="lineNum">    1398 </span>            : // UTF-8.
<span class="lineNum">    1399 </span>            : 
<span class="lineNum">    1400 </span>            : // A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
<span class="lineNum">    1401 </span>            : // like this:
<span class="lineNum">    1402 </span>            : //
<span class="lineNum">    1403 </span>            : // Code-point length   Encoding
<span class="lineNum">    1404 </span>            : //   0 -  7 bits       0xxxxxxx
<span class="lineNum">    1405 </span>            : //   8 - 11 bits       110xxxxx 10xxxxxx
<span class="lineNum">    1406 </span>            : //  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx
<span class="lineNum">    1407 </span>            : //  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
<span class="lineNum">    1408 </span>            : 
<span class="lineNum">    1409 </span>            : // The maximum code-point a one-byte UTF-8 sequence can represent.
<span class="lineNum">    1410 </span>            : const UInt32 kMaxCodePoint1 = (static_cast&lt;UInt32&gt;(1) &lt;&lt;  7) - 1;
<span class="lineNum">    1411 </span>            : 
<span class="lineNum">    1412 </span>            : // The maximum code-point a two-byte UTF-8 sequence can represent.
<span class="lineNum">    1413 </span>            : const UInt32 kMaxCodePoint2 = (static_cast&lt;UInt32&gt;(1) &lt;&lt; (5 + 6)) - 1;
<span class="lineNum">    1414 </span>            : 
<span class="lineNum">    1415 </span>            : // The maximum code-point a three-byte UTF-8 sequence can represent.
<span class="lineNum">    1416 </span>            : const UInt32 kMaxCodePoint3 = (static_cast&lt;UInt32&gt;(1) &lt;&lt; (4 + 2*6)) - 1;
<span class="lineNum">    1417 </span>            : 
<span class="lineNum">    1418 </span>            : // The maximum code-point a four-byte UTF-8 sequence can represent.
<span class="lineNum">    1419 </span>            : const UInt32 kMaxCodePoint4 = (static_cast&lt;UInt32&gt;(1) &lt;&lt; (3 + 3*6)) - 1;
<span class="lineNum">    1420 </span>            : 
<span class="lineNum">    1421 </span>            : // Chops off the n lowest bits from a bit pattern.  Returns the n
<a name="1422"><span class="lineNum">    1422 </span>            : // lowest bits.  As a side effect, the original bit pattern will be</a>
<span class="lineNum">    1423 </span>            : // shifted to the right by n bits.
<span class="lineNum">    1424 </span><span class="lineNoCov">          0 : inline UInt32 ChopLowBits(UInt32* bits, int n) {</span>
<span class="lineNum">    1425 </span><span class="lineNoCov">          0 :   const UInt32 low_bits = *bits &amp; ((static_cast&lt;UInt32&gt;(1) &lt;&lt; n) - 1);</span>
<span class="lineNum">    1426 </span><span class="lineNoCov">          0 :   *bits &gt;&gt;= n;</span>
<span class="lineNum">    1427 </span><span class="lineNoCov">          0 :   return low_bits;</span>
<span class="lineNum">    1428 </span>            : }
<span class="lineNum">    1429 </span>            : 
<span class="lineNum">    1430 </span>            : // Converts a Unicode code point to a narrow string in UTF-8 encoding.
<span class="lineNum">    1431 </span>            : // code_point parameter is of type UInt32 because wchar_t may not be
<span class="lineNum">    1432 </span>            : // wide enough to contain a code point.
<span class="lineNum">    1433 </span>            : // If the code_point is not a valid Unicode code point
<a name="1434"><span class="lineNum">    1434 </span>            : // (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted</a>
<span class="lineNum">    1435 </span>            : // to &quot;(Invalid Unicode 0xXXXXXXXX)&quot;.
<span class="lineNum">    1436 </span><span class="lineNoCov">          0 : std::string CodePointToUtf8(UInt32 code_point) {</span>
<span class="lineNum">    1437 </span><span class="lineNoCov">          0 :   if (code_point &gt; kMaxCodePoint4) {</span>
<span class="lineNum">    1438 </span><span class="lineNoCov">          0 :     return &quot;(Invalid Unicode 0x&quot; + String::FormatHexInt(code_point) + &quot;)&quot;;</span>
<span class="lineNum">    1439 </span>            :   }
<span class="lineNum">    1440 </span>            : 
<span class="lineNum">    1441 </span>            :   char str[5];  // Big enough for the largest valid code point.
<span class="lineNum">    1442 </span><span class="lineNoCov">          0 :   if (code_point &lt;= kMaxCodePoint1) {</span>
<span class="lineNum">    1443 </span><span class="lineNoCov">          0 :     str[1] = '\0';</span>
<span class="lineNum">    1444 </span><span class="lineNoCov">          0 :     str[0] = static_cast&lt;char&gt;(code_point);                          // 0xxxxxxx</span>
<span class="lineNum">    1445 </span><span class="lineNoCov">          0 :   } else if (code_point &lt;= kMaxCodePoint2) {</span>
<span class="lineNum">    1446 </span><span class="lineNoCov">          0 :     str[2] = '\0';</span>
<span class="lineNum">    1447 </span><span class="lineNoCov">          0 :     str[1] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1448 </span><span class="lineNoCov">          0 :     str[0] = static_cast&lt;char&gt;(0xC0 | code_point);                   // 110xxxxx</span>
<span class="lineNum">    1449 </span><span class="lineNoCov">          0 :   } else if (code_point &lt;= kMaxCodePoint3) {</span>
<span class="lineNum">    1450 </span><span class="lineNoCov">          0 :     str[3] = '\0';</span>
<span class="lineNum">    1451 </span><span class="lineNoCov">          0 :     str[2] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1452 </span><span class="lineNoCov">          0 :     str[1] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1453 </span><span class="lineNoCov">          0 :     str[0] = static_cast&lt;char&gt;(0xE0 | code_point);                   // 1110xxxx</span>
<span class="lineNum">    1454 </span>            :   } else {  // code_point &lt;= kMaxCodePoint4
<span class="lineNum">    1455 </span><span class="lineNoCov">          0 :     str[4] = '\0';</span>
<span class="lineNum">    1456 </span><span class="lineNoCov">          0 :     str[3] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1457 </span><span class="lineNoCov">          0 :     str[2] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1458 </span><span class="lineNoCov">          0 :     str[1] = static_cast&lt;char&gt;(0x80 | ChopLowBits(&amp;code_point, 6));  // 10xxxxxx</span>
<span class="lineNum">    1459 </span><span class="lineNoCov">          0 :     str[0] = static_cast&lt;char&gt;(0xF0 | code_point);                   // 11110xxx</span>
<span class="lineNum">    1460 </span>            :   }
<span class="lineNum">    1461 </span><span class="lineNoCov">          0 :   return str;</span>
<span class="lineNum">    1462 </span>            : }
<span class="lineNum">    1463 </span>            : 
<span class="lineNum">    1464 </span>            : // The following two functions only make sense if the the system
<span class="lineNum">    1465 </span>            : // uses UTF-16 for wide string encoding. All supported systems
<span class="lineNum">    1466 </span>            : // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
<span class="lineNum">    1467 </span>            : 
<span class="lineNum">    1468 </span>            : // Determines if the arguments constitute UTF-16 surrogate pair
<a name="1469"><span class="lineNum">    1469 </span>            : // and thus should be combined into a single Unicode code point</a>
<span class="lineNum">    1470 </span>            : // using CreateCodePointFromUtf16SurrogatePair.
<span class="lineNum">    1471 </span><span class="lineNoCov">          0 : inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {</span>
<span class="lineNum">    1472 </span>            :   return sizeof(wchar_t) == 2 &amp;&amp;
<span class="lineNum">    1473 </span><span class="lineNoCov">          0 :       (first &amp; 0xFC00) == 0xD800 &amp;&amp; (second &amp; 0xFC00) == 0xDC00;</span>
<span class="lineNum">    1474 </span>            : }
<a name="1475"><span class="lineNum">    1475 </span>            : </a>
<span class="lineNum">    1476 </span>            : // Creates a Unicode code point from UTF16 surrogate pair.
<span class="lineNum">    1477 </span><span class="lineNoCov">          0 : inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,</span>
<span class="lineNum">    1478 </span>            :                                                     wchar_t second) {
<span class="lineNum">    1479 </span><span class="lineNoCov">          0 :   const UInt32 mask = (1 &lt;&lt; 10) - 1;</span>
<span class="lineNum">    1480 </span>            :   return (sizeof(wchar_t) == 2) ?
<span class="lineNum">    1481 </span>            :       (((first &amp; mask) &lt;&lt; 10) | (second &amp; mask)) + 0x10000 :
<span class="lineNum">    1482 </span>            :       // This function should not be called when the condition is
<span class="lineNum">    1483 </span>            :       // false, but we provide a sensible default in case it is.
<span class="lineNum">    1484 </span><span class="lineNoCov">          0 :       static_cast&lt;UInt32&gt;(first);</span>
<span class="lineNum">    1485 </span>            : }
<span class="lineNum">    1486 </span>            : 
<span class="lineNum">    1487 </span>            : // Converts a wide string to a narrow string in UTF-8 encoding.
<span class="lineNum">    1488 </span>            : // The wide string is assumed to have the following encoding:
<span class="lineNum">    1489 </span>            : //   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
<span class="lineNum">    1490 </span>            : //   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
<span class="lineNum">    1491 </span>            : // Parameter str points to a null-terminated wide string.
<span class="lineNum">    1492 </span>            : // Parameter num_chars may additionally limit the number
<span class="lineNum">    1493 </span>            : // of wchar_t characters processed. -1 is used when the entire string
<span class="lineNum">    1494 </span>            : // should be processed.
<span class="lineNum">    1495 </span>            : // If the string contains code points that are not valid Unicode code points
<span class="lineNum">    1496 </span>            : // (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
<span class="lineNum">    1497 </span>            : // as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
<a name="1498"><span class="lineNum">    1498 </span>            : // and contains invalid UTF-16 surrogate pairs, values in those pairs</a>
<span class="lineNum">    1499 </span>            : // will be encoded as individual Unicode characters from Basic Normal Plane.
<span class="lineNum">    1500 </span><span class="lineNoCov">          0 : std::string WideStringToUtf8(const wchar_t* str, int num_chars) {</span>
<span class="lineNum">    1501 </span><span class="lineNoCov">          0 :   if (num_chars == -1)</span>
<span class="lineNum">    1502 </span><span class="lineNoCov">          0 :     num_chars = static_cast&lt;int&gt;(wcslen(str));</span>
<span class="lineNum">    1503 </span>            : 
<span class="lineNum">    1504 </span><span class="lineNoCov">          0 :   ::std::stringstream stream;</span>
<span class="lineNum">    1505 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; num_chars; ++i) {</span>
<span class="lineNum">    1506 </span>            :     UInt32 unicode_code_point;
<span class="lineNum">    1507 </span>            : 
<span class="lineNum">    1508 </span><span class="lineNoCov">          0 :     if (str[i] == L'\0') {</span>
<span class="lineNum">    1509 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">    1510 </span><span class="lineNoCov">          0 :     } else if (i + 1 &lt; num_chars &amp;&amp; IsUtf16SurrogatePair(str[i], str[i + 1])) {</span>
<span class="lineNum">    1511 </span><span class="lineNoCov">          0 :       unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],</span>
<span class="lineNum">    1512 </span><span class="lineNoCov">          0 :                                                                  str[i + 1]);</span>
<span class="lineNum">    1513 </span><span class="lineNoCov">          0 :       i++;</span>
<span class="lineNum">    1514 </span>            :     } else {
<span class="lineNum">    1515 </span><span class="lineNoCov">          0 :       unicode_code_point = static_cast&lt;UInt32&gt;(str[i]);</span>
<span class="lineNum">    1516 </span>            :     }
<span class="lineNum">    1517 </span>            : 
<span class="lineNum">    1518 </span><span class="lineNoCov">          0 :     stream &lt;&lt; CodePointToUtf8(unicode_code_point);</span>
<span class="lineNum">    1519 </span>            :   }
<span class="lineNum">    1520 </span><span class="lineNoCov">          0 :   return StringStreamToString(&amp;stream);</span>
<span class="lineNum">    1521 </span>            : }
<span class="lineNum">    1522 </span>            : 
<a name="1523"><span class="lineNum">    1523 </span>            : // Converts a wide C string to an std::string using the UTF-8 encoding.</a>
<span class="lineNum">    1524 </span>            : // NULL will be converted to &quot;(null)&quot;.
<span class="lineNum">    1525 </span><span class="lineNoCov">          0 : std::string String::ShowWideCString(const wchar_t * wide_c_str) {</span>
<span class="lineNum">    1526 </span><span class="lineNoCov">          0 :   if (wide_c_str == NULL)  return &quot;(null)&quot;;</span>
<span class="lineNum">    1527 </span>            : 
<span class="lineNum">    1528 </span><span class="lineNoCov">          0 :   return internal::WideStringToUtf8(wide_c_str, -1);</span>
<span class="lineNum">    1529 </span>            : }
<span class="lineNum">    1530 </span>            : 
<span class="lineNum">    1531 </span>            : // Compares two wide C strings.  Returns true iff they have the same
<span class="lineNum">    1532 </span>            : // content.
<span class="lineNum">    1533 </span>            : //
<span class="lineNum">    1534 </span>            : // Unlike wcscmp(), this function can handle NULL argument(s).  A NULL
<a name="1535"><span class="lineNum">    1535 </span>            : // C string is considered different to any non-NULL C string,</a>
<span class="lineNum">    1536 </span>            : // including the empty string.
<span class="lineNum">    1537 </span><span class="lineNoCov">          0 : bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {</span>
<span class="lineNum">    1538 </span><span class="lineNoCov">          0 :   if (lhs == NULL) return rhs == NULL;</span>
<span class="lineNum">    1539 </span>            : 
<span class="lineNum">    1540 </span><span class="lineNoCov">          0 :   if (rhs == NULL) return false;</span>
<span class="lineNum">    1541 </span>            : 
<span class="lineNum">    1542 </span><span class="lineNoCov">          0 :   return wcscmp(lhs, rhs) == 0;</span>
<span class="lineNum">    1543 </span>            : }
<a name="1544"><span class="lineNum">    1544 </span>            : </a>
<span class="lineNum">    1545 </span>            : // Helper function for *_STREQ on wide strings.
<span class="lineNum">    1546 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTREQ(const char* expected_expression,</span>
<span class="lineNum">    1547 </span>            :                                const char* actual_expression,
<span class="lineNum">    1548 </span>            :                                const wchar_t* expected,
<span class="lineNum">    1549 </span>            :                                const wchar_t* actual) {
<span class="lineNum">    1550 </span><span class="lineNoCov">          0 :   if (String::WideCStringEquals(expected, actual)) {</span>
<span class="lineNum">    1551 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1552 </span>            :   }
<span class="lineNum">    1553 </span>            : 
<span class="lineNum">    1554 </span>            :   return EqFailure(expected_expression,
<span class="lineNum">    1555 </span>            :                    actual_expression,
<span class="lineNum">    1556 </span><span class="lineNoCov">          0 :                    PrintToString(expected),</span>
<span class="lineNum">    1557 </span><span class="lineNoCov">          0 :                    PrintToString(actual),</span>
<span class="lineNum">    1558 </span><span class="lineNoCov">          0 :                    false);</span>
<span class="lineNum">    1559 </span>            : }
<a name="1560"><span class="lineNum">    1560 </span>            : </a>
<span class="lineNum">    1561 </span>            : // Helper function for *_STRNE on wide strings.
<span class="lineNum">    1562 </span><span class="lineNoCov">          0 : AssertionResult CmpHelperSTRNE(const char* s1_expression,</span>
<span class="lineNum">    1563 </span>            :                                const char* s2_expression,
<span class="lineNum">    1564 </span>            :                                const wchar_t* s1,
<span class="lineNum">    1565 </span>            :                                const wchar_t* s2) {
<span class="lineNum">    1566 </span><span class="lineNoCov">          0 :   if (!String::WideCStringEquals(s1, s2)) {</span>
<span class="lineNum">    1567 </span><span class="lineNoCov">          0 :     return AssertionSuccess();</span>
<span class="lineNum">    1568 </span>            :   }
<span class="lineNum">    1569 </span>            : 
<span class="lineNum">    1570 </span><span class="lineNoCov">          0 :   return AssertionFailure() &lt;&lt; &quot;Expected: (&quot; &lt;&lt; s1_expression &lt;&lt; &quot;) != (&quot;</span>
<span class="lineNum">    1571 </span><span class="lineNoCov">          0 :                             &lt;&lt; s2_expression &lt;&lt; &quot;), actual: &quot;</span>
<span class="lineNum">    1572 </span><span class="lineNoCov">          0 :                             &lt;&lt; PrintToString(s1)</span>
<span class="lineNum">    1573 </span><span class="lineNoCov">          0 :                             &lt;&lt; &quot; vs &quot; &lt;&lt; PrintToString(s2);</span>
<span class="lineNum">    1574 </span>            : }
<span class="lineNum">    1575 </span>            : 
<span class="lineNum">    1576 </span>            : // Compares two C strings, ignoring case.  Returns true iff they have
<span class="lineNum">    1577 </span>            : // the same content.
<span class="lineNum">    1578 </span>            : //
<span class="lineNum">    1579 </span>            : // Unlike strcasecmp(), this function can handle NULL argument(s).  A
<a name="1580"><span class="lineNum">    1580 </span>            : // NULL C string is considered different to any non-NULL C string,</a>
<span class="lineNum">    1581 </span>            : // including the empty string.
<span class="lineNum">    1582 </span><span class="lineNoCov">          0 : bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {</span>
<span class="lineNum">    1583 </span><span class="lineNoCov">          0 :   if (lhs == NULL)</span>
<span class="lineNum">    1584 </span><span class="lineNoCov">          0 :     return rhs == NULL;</span>
<span class="lineNum">    1585 </span><span class="lineNoCov">          0 :   if (rhs == NULL)</span>
<span class="lineNum">    1586 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    1587 </span><span class="lineNoCov">          0 :   return posix::StrCaseCmp(lhs, rhs) == 0;</span>
<span class="lineNum">    1588 </span>            : }
<span class="lineNum">    1589 </span>            : 
<span class="lineNum">    1590 </span>            :   // Compares two wide C strings, ignoring case.  Returns true iff they
<span class="lineNum">    1591 </span>            :   // have the same content.
<span class="lineNum">    1592 </span>            :   //
<span class="lineNum">    1593 </span>            :   // Unlike wcscasecmp(), this function can handle NULL argument(s).
<span class="lineNum">    1594 </span>            :   // A NULL C string is considered different to any non-NULL wide C string,
<span class="lineNum">    1595 </span>            :   // including the empty string.
<span class="lineNum">    1596 </span>            :   // NB: The implementations on different platforms slightly differ.
<span class="lineNum">    1597 </span>            :   // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
<span class="lineNum">    1598 </span>            :   // environment variable. On GNU platform this method uses wcscasecmp
<span class="lineNum">    1599 </span>            :   // which compares according to LC_CTYPE category of the current locale.
<a name="1600"><span class="lineNum">    1600 </span>            :   // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the</a>
<span class="lineNum">    1601 </span>            :   // current locale.
<span class="lineNum">    1602 </span><span class="lineNoCov">          0 : bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,</span>
<span class="lineNum">    1603 </span>            :                                               const wchar_t* rhs) {
<span class="lineNum">    1604 </span><span class="lineNoCov">          0 :   if (lhs == NULL) return rhs == NULL;</span>
<span class="lineNum">    1605 </span>            : 
<span class="lineNum">    1606 </span><span class="lineNoCov">          0 :   if (rhs == NULL) return false;</span>
<span class="lineNum">    1607 </span>            : 
<span class="lineNum">    1608 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    1609 </span>            :   return _wcsicmp(lhs, rhs) == 0;
<span class="lineNum">    1610 </span>            : #elif GTEST_OS_LINUX &amp;&amp; !GTEST_OS_LINUX_ANDROID
<span class="lineNum">    1611 </span><span class="lineNoCov">          0 :   return wcscasecmp(lhs, rhs) == 0;</span>
<span class="lineNum">    1612 </span>            : #else
<span class="lineNum">    1613 </span>            :   // Android, Mac OS X and Cygwin don't define wcscasecmp.
<span class="lineNum">    1614 </span>            :   // Other unknown OSes may not define it either.
<span class="lineNum">    1615 </span>            :   wint_t left, right;
<span class="lineNum">    1616 </span>            :   do {
<span class="lineNum">    1617 </span>            :     left = towlower(*lhs++);
<span class="lineNum">    1618 </span>            :     right = towlower(*rhs++);
<span class="lineNum">    1619 </span>            :   } while (left &amp;&amp; left == right);
<span class="lineNum">    1620 </span>            :   return left == right;
<span class="lineNum">    1621 </span>            : #endif  // OS selector
<span class="lineNum">    1622 </span>            : }
<span class="lineNum">    1623 </span>            : 
<a name="1624"><span class="lineNum">    1624 </span>            : // Returns true iff str ends with the given suffix, ignoring case.</a>
<span class="lineNum">    1625 </span>            : // Any string is considered to end with an empty suffix.
<span class="lineNum">    1626 </span><span class="lineNoCov">          0 : bool String::EndsWithCaseInsensitive(</span>
<span class="lineNum">    1627 </span>            :     const std::string&amp; str, const std::string&amp; suffix) {
<span class="lineNum">    1628 </span><span class="lineNoCov">          0 :   const size_t str_len = str.length();</span>
<span class="lineNum">    1629 </span><span class="lineNoCov">          0 :   const size_t suffix_len = suffix.length();</span>
<span class="lineNum">    1630 </span><span class="lineNoCov">          0 :   return (str_len &gt;= suffix_len) &amp;&amp;</span>
<span class="lineNum">    1631 </span><span class="lineNoCov">          0 :          CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,</span>
<span class="lineNum">    1632 </span><span class="lineNoCov">          0 :                                       suffix.c_str());</span>
<span class="lineNum">    1633 </span>            : }
<a name="1634"><span class="lineNum">    1634 </span>            : </a>
<span class="lineNum">    1635 </span>            : // Formats an int value as &quot;%02d&quot;.
<span class="lineNum">    1636 </span><span class="lineNoCov">          0 : std::string String::FormatIntWidth2(int value) {</span>
<span class="lineNum">    1637 </span><span class="lineNoCov">          0 :   std::stringstream ss;</span>
<span class="lineNum">    1638 </span><span class="lineNoCov">          0 :   ss &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; value;</span>
<span class="lineNum">    1639 </span><span class="lineNoCov">          0 :   return ss.str();</span>
<span class="lineNum">    1640 </span>            : }
<a name="1641"><span class="lineNum">    1641 </span>            : </a>
<span class="lineNum">    1642 </span>            : // Formats an int value as &quot;%X&quot;.
<span class="lineNum">    1643 </span><span class="lineNoCov">          0 : std::string String::FormatHexInt(int value) {</span>
<span class="lineNum">    1644 </span><span class="lineNoCov">          0 :   std::stringstream ss;</span>
<span class="lineNum">    1645 </span><span class="lineNoCov">          0 :   ss &lt;&lt; std::hex &lt;&lt; std::uppercase &lt;&lt; value;</span>
<span class="lineNum">    1646 </span><span class="lineNoCov">          0 :   return ss.str();</span>
<span class="lineNum">    1647 </span>            : }
<a name="1648"><span class="lineNum">    1648 </span>            : </a>
<span class="lineNum">    1649 </span>            : // Formats a byte as &quot;%02X&quot;.
<span class="lineNum">    1650 </span><span class="lineNoCov">          0 : std::string String::FormatByte(unsigned char value) {</span>
<span class="lineNum">    1651 </span><span class="lineNoCov">          0 :   std::stringstream ss;</span>
<span class="lineNum">    1652 </span><span class="lineNoCov">          0 :   ss &lt;&lt; std::setfill('0') &lt;&lt; std::setw(2) &lt;&lt; std::hex &lt;&lt; std::uppercase</span>
<span class="lineNum">    1653 </span><span class="lineNoCov">          0 :      &lt;&lt; static_cast&lt;unsigned int&gt;(value);</span>
<span class="lineNum">    1654 </span><span class="lineNoCov">          0 :   return ss.str();</span>
<span class="lineNum">    1655 </span>            : }
<span class="lineNum">    1656 </span>            : 
<a name="1657"><span class="lineNum">    1657 </span>            : // Converts the buffer in a stringstream to an std::string, converting NUL</a>
<span class="lineNum">    1658 </span>            : // bytes to &quot;\\0&quot; along the way.
<span class="lineNum">    1659 </span><span class="lineNoCov">          0 : std::string StringStreamToString(::std::stringstream* ss) {</span>
<span class="lineNum">    1660 </span><span class="lineNoCov">          0 :   const ::std::string&amp; str = ss-&gt;str();</span>
<span class="lineNum">    1661 </span><span class="lineNoCov">          0 :   const char* const start = str.c_str();</span>
<span class="lineNum">    1662 </span><span class="lineNoCov">          0 :   const char* const end = start + str.length();</span>
<span class="lineNum">    1663 </span>            : 
<span class="lineNum">    1664 </span><span class="lineNoCov">          0 :   std::string result;</span>
<span class="lineNum">    1665 </span><span class="lineNoCov">          0 :   result.reserve(2 * (end - start));</span>
<span class="lineNum">    1666 </span><span class="lineNoCov">          0 :   for (const char* ch = start; ch != end; ++ch) {</span>
<span class="lineNum">    1667 </span><span class="lineNoCov">          0 :     if (*ch == '\0') {</span>
<span class="lineNum">    1668 </span><span class="lineNoCov">          0 :       result += &quot;\\0&quot;;  // Replaces NUL with &quot;\\0&quot;;</span>
<span class="lineNum">    1669 </span>            :     } else {
<span class="lineNum">    1670 </span><span class="lineNoCov">          0 :       result += *ch;</span>
<span class="lineNum">    1671 </span>            :     }
<span class="lineNum">    1672 </span>            :   }
<span class="lineNum">    1673 </span>            : 
<span class="lineNum">    1674 </span><span class="lineNoCov">          0 :   return result;</span>
<span class="lineNum">    1675 </span>            : }
<a name="1676"><span class="lineNum">    1676 </span>            : </a>
<span class="lineNum">    1677 </span>            : // Appends the user-supplied message to the Google-Test-generated message.
<span class="lineNum">    1678 </span><span class="lineNoCov">          0 : std::string AppendUserMessage(const std::string&amp; gtest_msg,</span>
<span class="lineNum">    1679 </span>            :                               const Message&amp; user_msg) {
<span class="lineNum">    1680 </span>            :   // Appends the user message if it's non-empty.
<span class="lineNum">    1681 </span><span class="lineNoCov">          0 :   const std::string user_msg_string = user_msg.GetString();</span>
<span class="lineNum">    1682 </span><span class="lineNoCov">          0 :   if (user_msg_string.empty()) {</span>
<span class="lineNum">    1683 </span><span class="lineNoCov">          0 :     return gtest_msg;</span>
<span class="lineNum">    1684 </span>            :   }
<span class="lineNum">    1685 </span>            : 
<span class="lineNum">    1686 </span><span class="lineNoCov">          0 :   return gtest_msg + &quot;\n&quot; + user_msg_string;</span>
<span class="lineNum">    1687 </span>            : }
<span class="lineNum">    1688 </span>            : 
<span class="lineNum">    1689 </span>            : }  // namespace internal
<span class="lineNum">    1690 </span>            : 
<span class="lineNum">    1691 </span>            : // class TestResult
<a name="1692"><span class="lineNum">    1692 </span>            : </a>
<span class="lineNum">    1693 </span>            : // Creates an empty TestResult.
<span class="lineNum">    1694 </span><span class="lineNoCov">          0 : TestResult::TestResult()</span>
<span class="lineNum">    1695 </span>            :     : death_test_count_(0),
<span class="lineNum">    1696 </span><span class="lineNoCov">          0 :       elapsed_time_(0) {</span>
<span class="lineNum">    1697 </span><span class="lineNoCov">          0 : }</span>
<a name="1698"><span class="lineNum">    1698 </span>            : </a>
<span class="lineNum">    1699 </span>            : // D'tor.
<span class="lineNum">    1700 </span><span class="lineNoCov">          0 : TestResult::~TestResult() {</span>
<span class="lineNum">    1701 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1702 </span>            : 
<span class="lineNum">    1703 </span>            : // Returns the i-th test part result among all the results. i can
<a name="1704"><span class="lineNum">    1704 </span>            : // range from 0 to total_part_count() - 1. If i is not in that range,</a>
<span class="lineNum">    1705 </span>            : // aborts the program.
<span class="lineNum">    1706 </span><span class="lineNoCov">          0 : const TestPartResult&amp; TestResult::GetTestPartResult(int i) const {</span>
<span class="lineNum">    1707 </span><span class="lineNoCov">          0 :   if (i &lt; 0 || i &gt;= total_part_count())</span>
<span class="lineNum">    1708 </span><span class="lineNoCov">          0 :     internal::posix::Abort();</span>
<span class="lineNum">    1709 </span><span class="lineNoCov">          0 :   return test_part_results_.at(i);</span>
<span class="lineNum">    1710 </span>            : }
<span class="lineNum">    1711 </span>            : 
<span class="lineNum">    1712 </span>            : // Returns the i-th test property. i can range from 0 to
<a name="1713"><span class="lineNum">    1713 </span>            : // test_property_count() - 1. If i is not in that range, aborts the</a>
<span class="lineNum">    1714 </span>            : // program.
<span class="lineNum">    1715 </span><span class="lineNoCov">          0 : const TestProperty&amp; TestResult::GetTestProperty(int i) const {</span>
<span class="lineNum">    1716 </span><span class="lineNoCov">          0 :   if (i &lt; 0 || i &gt;= test_property_count())</span>
<span class="lineNum">    1717 </span><span class="lineNoCov">          0 :     internal::posix::Abort();</span>
<span class="lineNum">    1718 </span><span class="lineNoCov">          0 :   return test_properties_.at(i);</span>
<span class="lineNum">    1719 </span>            : }
<a name="1720"><span class="lineNum">    1720 </span>            : </a>
<span class="lineNum">    1721 </span>            : // Clears the test part results.
<span class="lineNum">    1722 </span><span class="lineNoCov">          0 : void TestResult::ClearTestPartResults() {</span>
<span class="lineNum">    1723 </span><span class="lineNoCov">          0 :   test_part_results_.clear();</span>
<span class="lineNum">    1724 </span><span class="lineNoCov">          0 : }</span>
<a name="1725"><span class="lineNum">    1725 </span>            : </a>
<span class="lineNum">    1726 </span>            : // Adds a test part result to the list.
<span class="lineNum">    1727 </span><span class="lineNoCov">          0 : void TestResult::AddTestPartResult(const TestPartResult&amp; test_part_result) {</span>
<span class="lineNum">    1728 </span><span class="lineNoCov">          0 :   test_part_results_.push_back(test_part_result);</span>
<span class="lineNum">    1729 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1730 </span>            : 
<span class="lineNum">    1731 </span>            : // Adds a test property to the list. If a property with the same key as the
<a name="1732"><span class="lineNum">    1732 </span>            : // supplied property is already represented, the value of this test_property</a>
<span class="lineNum">    1733 </span>            : // replaces the old value for that key.
<span class="lineNum">    1734 </span><span class="lineNoCov">          0 : void TestResult::RecordProperty(const std::string&amp; xml_element,</span>
<span class="lineNum">    1735 </span>            :                                 const TestProperty&amp; test_property) {
<span class="lineNum">    1736 </span><span class="lineNoCov">          0 :   if (!ValidateTestProperty(xml_element, test_property)) {</span>
<span class="lineNum">    1737 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">    1738 </span>            :   }
<span class="lineNum">    1739 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;test_properites_mutex_);</span>
<span class="lineNum">    1740 </span>            :   const std::vector&lt;TestProperty&gt;::iterator property_with_matching_key =
<span class="lineNum">    1741 </span>            :       std::find_if(test_properties_.begin(), test_properties_.end(),
<span class="lineNum">    1742 </span><span class="lineNoCov">          0 :                    internal::TestPropertyKeyIs(test_property.key()));</span>
<span class="lineNum">    1743 </span><span class="lineNoCov">          0 :   if (property_with_matching_key == test_properties_.end()) {</span>
<span class="lineNum">    1744 </span><span class="lineNoCov">          0 :     test_properties_.push_back(test_property);</span>
<span class="lineNum">    1745 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">    1746 </span>            :   }
<span class="lineNum">    1747 </span><span class="lineNoCov">          0 :   property_with_matching_key-&gt;SetValue(test_property.value());</span>
<span class="lineNum">    1748 </span>            : }
<span class="lineNum">    1749 </span>            : 
<span class="lineNum">    1750 </span>            : // The list of reserved attributes used in the &lt;testsuites&gt; element of XML
<span class="lineNum">    1751 </span>            : // output.
<span class="lineNum">    1752 </span>            : static const char* const kReservedTestSuitesAttributes[] = {
<span class="lineNum">    1753 </span>            :   &quot;disabled&quot;,
<span class="lineNum">    1754 </span>            :   &quot;errors&quot;,
<span class="lineNum">    1755 </span>            :   &quot;failures&quot;,
<span class="lineNum">    1756 </span>            :   &quot;name&quot;,
<span class="lineNum">    1757 </span>            :   &quot;random_seed&quot;,
<span class="lineNum">    1758 </span>            :   &quot;tests&quot;,
<span class="lineNum">    1759 </span>            :   &quot;time&quot;,
<span class="lineNum">    1760 </span>            :   &quot;timestamp&quot;
<span class="lineNum">    1761 </span>            : };
<span class="lineNum">    1762 </span>            : 
<span class="lineNum">    1763 </span>            : // The list of reserved attributes used in the &lt;testsuite&gt; element of XML
<span class="lineNum">    1764 </span>            : // output.
<span class="lineNum">    1765 </span>            : static const char* const kReservedTestSuiteAttributes[] = {
<span class="lineNum">    1766 </span>            :   &quot;disabled&quot;,
<span class="lineNum">    1767 </span>            :   &quot;errors&quot;,
<span class="lineNum">    1768 </span>            :   &quot;failures&quot;,
<span class="lineNum">    1769 </span>            :   &quot;name&quot;,
<span class="lineNum">    1770 </span>            :   &quot;tests&quot;,
<span class="lineNum">    1771 </span>            :   &quot;time&quot;
<span class="lineNum">    1772 </span>            : };
<span class="lineNum">    1773 </span>            : 
<span class="lineNum">    1774 </span>            : // The list of reserved attributes used in the &lt;testcase&gt; element of XML output.
<span class="lineNum">    1775 </span>            : static const char* const kReservedTestCaseAttributes[] = {
<span class="lineNum">    1776 </span>            :   &quot;classname&quot;,
<span class="lineNum">    1777 </span>            :   &quot;name&quot;,
<span class="lineNum">    1778 </span>            :   &quot;status&quot;,
<span class="lineNum">    1779 </span>            :   &quot;time&quot;,
<span class="lineNum">    1780 </span>            :   &quot;type_param&quot;,
<span class="lineNum">    1781 </span>            :   &quot;value_param&quot;
<span class="lineNum">    1782 </span>            : };
<a name="1783"><span class="lineNum">    1783 </span>            : </a>
<span class="lineNum">    1784 </span>            : template &lt;int kSize&gt;
<span class="lineNum">    1785 </span><span class="lineNoCov">          0 : std::vector&lt;std::string&gt; ArrayAsVector(const char* const (&amp;array)[kSize]) {</span>
<span class="lineNum">    1786 </span><span class="lineNoCov">          0 :   return std::vector&lt;std::string&gt;(array, array + kSize);</span>
<a name="1787"><span class="lineNum">    1787 </span>            : }</a>
<span class="lineNum">    1788 </span>            : 
<span class="lineNum">    1789 </span><span class="lineNoCov">          0 : static std::vector&lt;std::string&gt; GetReservedAttributesForElement(</span>
<span class="lineNum">    1790 </span>            :     const std::string&amp; xml_element) {
<span class="lineNum">    1791 </span><span class="lineNoCov">          0 :   if (xml_element == &quot;testsuites&quot;) {</span>
<span class="lineNum">    1792 </span><span class="lineNoCov">          0 :     return ArrayAsVector(kReservedTestSuitesAttributes);</span>
<span class="lineNum">    1793 </span><span class="lineNoCov">          0 :   } else if (xml_element == &quot;testsuite&quot;) {</span>
<span class="lineNum">    1794 </span><span class="lineNoCov">          0 :     return ArrayAsVector(kReservedTestSuiteAttributes);</span>
<span class="lineNum">    1795 </span><span class="lineNoCov">          0 :   } else if (xml_element == &quot;testcase&quot;) {</span>
<span class="lineNum">    1796 </span><span class="lineNoCov">          0 :     return ArrayAsVector(kReservedTestCaseAttributes);</span>
<span class="lineNum">    1797 </span>            :   } else {
<span class="lineNum">    1798 </span><span class="lineNoCov">          0 :     GTEST_CHECK_(false) &lt;&lt; &quot;Unrecognized xml_element provided: &quot; &lt;&lt; xml_element;</span>
<span class="lineNum">    1799 </span>            :   }
<span class="lineNum">    1800 </span>            :   // This code is unreachable but some compilers may not realizes that.
<span class="lineNum">    1801 </span><span class="lineNoCov">          0 :   return std::vector&lt;std::string&gt;();</span>
<a name="1802"><span class="lineNum">    1802 </span>            : }</a>
<span class="lineNum">    1803 </span>            : 
<span class="lineNum">    1804 </span><span class="lineNoCov">          0 : static std::string FormatWordList(const std::vector&lt;std::string&gt;&amp; words) {</span>
<span class="lineNum">    1805 </span><span class="lineNoCov">          0 :   Message word_list;</span>
<span class="lineNum">    1806 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; words.size(); ++i) {</span>
<span class="lineNum">    1807 </span><span class="lineNoCov">          0 :     if (i &gt; 0 &amp;&amp; words.size() &gt; 2) {</span>
<span class="lineNum">    1808 </span><span class="lineNoCov">          0 :       word_list &lt;&lt; &quot;, &quot;;</span>
<span class="lineNum">    1809 </span>            :     }
<span class="lineNum">    1810 </span><span class="lineNoCov">          0 :     if (i == words.size() - 1) {</span>
<span class="lineNum">    1811 </span><span class="lineNoCov">          0 :       word_list &lt;&lt; &quot;and &quot;;</span>
<span class="lineNum">    1812 </span>            :     }
<span class="lineNum">    1813 </span><span class="lineNoCov">          0 :     word_list &lt;&lt; &quot;'&quot; &lt;&lt; words[i] &lt;&lt; &quot;'&quot;;</span>
<span class="lineNum">    1814 </span>            :   }
<span class="lineNum">    1815 </span><span class="lineNoCov">          0 :   return word_list.GetString();</span>
<a name="1816"><span class="lineNum">    1816 </span>            : }</a>
<span class="lineNum">    1817 </span>            : 
<span class="lineNum">    1818 </span><span class="lineNoCov">          0 : bool ValidateTestPropertyName(const std::string&amp; property_name,</span>
<span class="lineNum">    1819 </span>            :                               const std::vector&lt;std::string&gt;&amp; reserved_names) {
<span class="lineNum">    1820 </span><span class="lineNoCov">          0 :   if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=</span>
<span class="lineNum">    1821 </span><span class="lineNoCov">          0 :           reserved_names.end()) {</span>
<span class="lineNum">    1822 </span><span class="lineNoCov">          0 :     ADD_FAILURE() &lt;&lt; &quot;Reserved key used in RecordProperty(): &quot; &lt;&lt; property_name</span>
<span class="lineNum">    1823 </span><span class="lineNoCov">          0 :                   &lt;&lt; &quot; (&quot; &lt;&lt; FormatWordList(reserved_names)</span>
<span class="lineNum">    1824 </span><span class="lineNoCov">          0 :                   &lt;&lt; &quot; are reserved by &quot; &lt;&lt; GTEST_NAME_ &lt;&lt; &quot;)&quot;;</span>
<span class="lineNum">    1825 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    1826 </span>            :   }
<span class="lineNum">    1827 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    1828 </span>            : }
<span class="lineNum">    1829 </span>            : 
<a name="1830"><span class="lineNum">    1830 </span>            : // Adds a failure if the key is a reserved attribute of the element named</a>
<span class="lineNum">    1831 </span>            : // xml_element.  Returns true if the property is valid.
<span class="lineNum">    1832 </span><span class="lineNoCov">          0 : bool TestResult::ValidateTestProperty(const std::string&amp; xml_element,</span>
<span class="lineNum">    1833 </span>            :                                       const TestProperty&amp; test_property) {
<span class="lineNum">    1834 </span><span class="lineNoCov">          0 :   return ValidateTestPropertyName(test_property.key(),</span>
<span class="lineNum">    1835 </span><span class="lineNoCov">          0 :                                   GetReservedAttributesForElement(xml_element));</span>
<span class="lineNum">    1836 </span>            : }
<a name="1837"><span class="lineNum">    1837 </span>            : </a>
<span class="lineNum">    1838 </span>            : // Clears the object.
<span class="lineNum">    1839 </span><span class="lineNoCov">          0 : void TestResult::Clear() {</span>
<span class="lineNum">    1840 </span><span class="lineNoCov">          0 :   test_part_results_.clear();</span>
<span class="lineNum">    1841 </span><span class="lineNoCov">          0 :   test_properties_.clear();</span>
<span class="lineNum">    1842 </span><span class="lineNoCov">          0 :   death_test_count_ = 0;</span>
<span class="lineNum">    1843 </span><span class="lineNoCov">          0 :   elapsed_time_ = 0;</span>
<span class="lineNum">    1844 </span><span class="lineNoCov">          0 : }</span>
<a name="1845"><span class="lineNum">    1845 </span>            : </a>
<span class="lineNum">    1846 </span>            : // Returns true iff the test failed.
<span class="lineNum">    1847 </span><span class="lineNoCov">          0 : bool TestResult::Failed() const {</span>
<span class="lineNum">    1848 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; total_part_count(); ++i) {</span>
<span class="lineNum">    1849 </span><span class="lineNoCov">          0 :     if (GetTestPartResult(i).failed())</span>
<span class="lineNum">    1850 </span><span class="lineNoCov">          0 :       return true;</span>
<span class="lineNum">    1851 </span>            :   }
<span class="lineNum">    1852 </span><span class="lineNoCov">          0 :   return false;</span>
<span class="lineNum">    1853 </span>            : }
<a name="1854"><span class="lineNum">    1854 </span>            : </a>
<span class="lineNum">    1855 </span>            : // Returns true iff the test part fatally failed.
<span class="lineNum">    1856 </span><span class="lineNoCov">          0 : static bool TestPartFatallyFailed(const TestPartResult&amp; result) {</span>
<span class="lineNum">    1857 </span><span class="lineNoCov">          0 :   return result.fatally_failed();</span>
<span class="lineNum">    1858 </span>            : }
<a name="1859"><span class="lineNum">    1859 </span>            : </a>
<span class="lineNum">    1860 </span>            : // Returns true iff the test fatally failed.
<span class="lineNum">    1861 </span><span class="lineNoCov">          0 : bool TestResult::HasFatalFailure() const {</span>
<span class="lineNum">    1862 </span><span class="lineNoCov">          0 :   return CountIf(test_part_results_, TestPartFatallyFailed) &gt; 0;</span>
<span class="lineNum">    1863 </span>            : }
<a name="1864"><span class="lineNum">    1864 </span>            : </a>
<span class="lineNum">    1865 </span>            : // Returns true iff the test part non-fatally failed.
<span class="lineNum">    1866 </span><span class="lineNoCov">          0 : static bool TestPartNonfatallyFailed(const TestPartResult&amp; result) {</span>
<span class="lineNum">    1867 </span><span class="lineNoCov">          0 :   return result.nonfatally_failed();</span>
<span class="lineNum">    1868 </span>            : }
<a name="1869"><span class="lineNum">    1869 </span>            : </a>
<span class="lineNum">    1870 </span>            : // Returns true iff the test has a non-fatal failure.
<span class="lineNum">    1871 </span><span class="lineNoCov">          0 : bool TestResult::HasNonfatalFailure() const {</span>
<span class="lineNum">    1872 </span><span class="lineNoCov">          0 :   return CountIf(test_part_results_, TestPartNonfatallyFailed) &gt; 0;</span>
<span class="lineNum">    1873 </span>            : }
<span class="lineNum">    1874 </span>            : 
<a name="1875"><span class="lineNum">    1875 </span>            : // Gets the number of all test parts.  This is the sum of the number</a>
<span class="lineNum">    1876 </span>            : // of successful test parts and the number of failed test parts.
<span class="lineNum">    1877 </span><span class="lineNoCov">          0 : int TestResult::total_part_count() const {</span>
<span class="lineNum">    1878 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(test_part_results_.size());</span>
<span class="lineNum">    1879 </span>            : }
<a name="1880"><span class="lineNum">    1880 </span>            : </a>
<span class="lineNum">    1881 </span>            : // Returns the number of the test properties.
<span class="lineNum">    1882 </span><span class="lineNoCov">          0 : int TestResult::test_property_count() const {</span>
<span class="lineNum">    1883 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(test_properties_.size());</span>
<span class="lineNum">    1884 </span>            : }
<span class="lineNum">    1885 </span>            : 
<span class="lineNum">    1886 </span>            : // class Test
<span class="lineNum">    1887 </span>            : 
<span class="lineNum">    1888 </span>            : // Creates a Test object.
<a name="1889"><span class="lineNum">    1889 </span>            : </a>
<span class="lineNum">    1890 </span>            : // The c'tor saves the values of all Google Test flags.
<span class="lineNum">    1891 </span><span class="lineNoCov">          0 : Test::Test()</span>
<span class="lineNum">    1892 </span><span class="lineNoCov">          0 :     : gtest_flag_saver_(new internal::GTestFlagSaver) {</span>
<span class="lineNum">    1893 </span><span class="lineNoCov">          0 : }</span>
<a name="1894"><span class="lineNum">    1894 </span>            : </a>
<span class="lineNum">    1895 </span>            : // The d'tor restores the values of all Google Test flags.
<span class="lineNum">    1896 </span><span class="lineNoCov">          0 : Test::~Test() {</span>
<span class="lineNum">    1897 </span><span class="lineNoCov">          0 :   delete gtest_flag_saver_;</span>
<span class="lineNum">    1898 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1899 </span>            : 
<span class="lineNum">    1900 </span>            : // Sets up the test fixture.
<a name="1901"><span class="lineNum">    1901 </span>            : //</a>
<span class="lineNum">    1902 </span>            : // A sub-class may override this.
<span class="lineNum">    1903 </span><span class="lineNoCov">          0 : void Test::SetUp() {</span>
<span class="lineNum">    1904 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1905 </span>            : 
<span class="lineNum">    1906 </span>            : // Tears down the test fixture.
<a name="1907"><span class="lineNum">    1907 </span>            : //</a>
<span class="lineNum">    1908 </span>            : // A sub-class may override this.
<span class="lineNum">    1909 </span><span class="lineNoCov">          0 : void Test::TearDown() {</span>
<span class="lineNum">    1910 </span><span class="lineNoCov">          0 : }</span>
<a name="1911"><span class="lineNum">    1911 </span>            : </a>
<span class="lineNum">    1912 </span>            : // Allows user supplied key value pairs to be recorded for later output.
<span class="lineNum">    1913 </span><span class="lineNoCov">          0 : void Test::RecordProperty(const std::string&amp; key, const std::string&amp; value) {</span>
<span class="lineNum">    1914 </span><span class="lineNoCov">          0 :   UnitTest::GetInstance()-&gt;RecordProperty(key, value);</span>
<span class="lineNum">    1915 </span><span class="lineNoCov">          0 : }</span>
<a name="1916"><span class="lineNum">    1916 </span>            : </a>
<span class="lineNum">    1917 </span>            : // Allows user supplied key value pairs to be recorded for later output.
<span class="lineNum">    1918 </span><span class="lineNoCov">          0 : void Test::RecordProperty(const std::string&amp; key, int value) {</span>
<span class="lineNum">    1919 </span><span class="lineNoCov">          0 :   Message value_message;</span>
<span class="lineNum">    1920 </span><span class="lineNoCov">          0 :   value_message &lt;&lt; value;</span>
<span class="lineNum">    1921 </span><span class="lineNoCov">          0 :   RecordProperty(key, value_message.GetString().c_str());</span>
<span class="lineNum">    1922 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1923 </span>            : 
<a name="1924"><span class="lineNum">    1924 </span>            : namespace internal {</a>
<span class="lineNum">    1925 </span>            : 
<span class="lineNum">    1926 </span><span class="lineNoCov">          0 : void ReportFailureInUnknownLocation(TestPartResult::Type result_type,</span>
<span class="lineNum">    1927 </span>            :                                     const std::string&amp; message) {
<span class="lineNum">    1928 </span>            :   // This function is a friend of UnitTest and as such has access to
<span class="lineNum">    1929 </span>            :   // AddTestPartResult.
<span class="lineNum">    1930 </span><span class="lineNoCov">          0 :   UnitTest::GetInstance()-&gt;AddTestPartResult(</span>
<span class="lineNum">    1931 </span>            :       result_type,
<span class="lineNum">    1932 </span>            :       NULL,  // No info about the source file where the exception occurred.
<span class="lineNum">    1933 </span>            :       -1,    // We have no info on which line caused the exception.
<span class="lineNum">    1934 </span>            :       message,
<span class="lineNum">    1935 </span><span class="lineNoCov">          0 :       &quot;&quot;);   // No stack trace, either.</span>
<span class="lineNum">    1936 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1937 </span>            : 
<span class="lineNum">    1938 </span>            : }  // namespace internal
<span class="lineNum">    1939 </span>            : 
<span class="lineNum">    1940 </span>            : // Google Test requires all tests in the same test case to use the same test
<span class="lineNum">    1941 </span>            : // fixture class.  This function checks if the current test has the
<span class="lineNum">    1942 </span>            : // same fixture class as the first test in the current test case.  If
<a name="1943"><span class="lineNum">    1943 </span>            : // yes, it returns true; otherwise it generates a Google Test failure and</a>
<span class="lineNum">    1944 </span>            : // returns false.
<span class="lineNum">    1945 </span><span class="lineNoCov">          0 : bool Test::HasSameFixtureClass() {</span>
<span class="lineNum">    1946 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">    1947 </span><span class="lineNoCov">          0 :   const TestCase* const test_case = impl-&gt;current_test_case();</span>
<span class="lineNum">    1948 </span>            : 
<span class="lineNum">    1949 </span>            :   // Info about the first test in the current test case.
<span class="lineNum">    1950 </span><span class="lineNoCov">          0 :   const TestInfo* const first_test_info = test_case-&gt;test_info_list()[0];</span>
<span class="lineNum">    1951 </span><span class="lineNoCov">          0 :   const internal::TypeId first_fixture_id = first_test_info-&gt;fixture_class_id_;</span>
<span class="lineNum">    1952 </span><span class="lineNoCov">          0 :   const char* const first_test_name = first_test_info-&gt;name();</span>
<span class="lineNum">    1953 </span>            : 
<span class="lineNum">    1954 </span>            :   // Info about the current test.
<span class="lineNum">    1955 </span><span class="lineNoCov">          0 :   const TestInfo* const this_test_info = impl-&gt;current_test_info();</span>
<span class="lineNum">    1956 </span><span class="lineNoCov">          0 :   const internal::TypeId this_fixture_id = this_test_info-&gt;fixture_class_id_;</span>
<span class="lineNum">    1957 </span><span class="lineNoCov">          0 :   const char* const this_test_name = this_test_info-&gt;name();</span>
<span class="lineNum">    1958 </span>            : 
<span class="lineNum">    1959 </span><span class="lineNoCov">          0 :   if (this_fixture_id != first_fixture_id) {</span>
<span class="lineNum">    1960 </span>            :     // Is the first test defined using TEST?
<span class="lineNum">    1961 </span><span class="lineNoCov">          0 :     const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();</span>
<span class="lineNum">    1962 </span>            :     // Is this test defined using TEST?
<span class="lineNum">    1963 </span><span class="lineNoCov">          0 :     const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();</span>
<span class="lineNum">    1964 </span>            : 
<span class="lineNum">    1965 </span><span class="lineNoCov">          0 :     if (first_is_TEST || this_is_TEST) {</span>
<span class="lineNum">    1966 </span>            :       // The user mixed TEST and TEST_F in this test case - we'll tell
<span class="lineNum">    1967 </span>            :       // him/her how to fix it.
<span class="lineNum">    1968 </span>            : 
<span class="lineNum">    1969 </span>            :       // Gets the name of the TEST and the name of the TEST_F.  Note
<span class="lineNum">    1970 </span>            :       // that first_is_TEST and this_is_TEST cannot both be true, as
<span class="lineNum">    1971 </span>            :       // the fixture IDs are different for the two tests.
<span class="lineNum">    1972 </span>            :       const char* const TEST_name =
<span class="lineNum">    1973 </span><span class="lineNoCov">          0 :           first_is_TEST ? first_test_name : this_test_name;</span>
<span class="lineNum">    1974 </span>            :       const char* const TEST_F_name =
<span class="lineNum">    1975 </span><span class="lineNoCov">          0 :           first_is_TEST ? this_test_name : first_test_name;</span>
<span class="lineNum">    1976 </span>            : 
<span class="lineNum">    1977 </span><span class="lineNoCov">          0 :       ADD_FAILURE()</span>
<span class="lineNum">    1978 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;All tests in the same test case must use the same test fixture\n&quot;</span>
<span class="lineNum">    1979 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;class, so mixing TEST_F and TEST in the same test case is\n&quot;</span>
<span class="lineNum">    1980 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;illegal.  In test case &quot; &lt;&lt; this_test_info-&gt;test_case_name()</span>
<span class="lineNum">    1981 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;,\n&quot;</span>
<span class="lineNum">    1982 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;test &quot; &lt;&lt; TEST_F_name &lt;&lt; &quot; is defined using TEST_F but\n&quot;</span>
<span class="lineNum">    1983 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;test &quot; &lt;&lt; TEST_name &lt;&lt; &quot; is defined using TEST.  You probably\n&quot;</span>
<span class="lineNum">    1984 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;want to change the TEST to TEST_F or move it to another test\n&quot;</span>
<span class="lineNum">    1985 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;case.&quot;;</span>
<span class="lineNum">    1986 </span>            :     } else {
<span class="lineNum">    1987 </span>            :       // The user defined two fixture classes with the same name in
<span class="lineNum">    1988 </span>            :       // two namespaces - we'll tell him/her how to fix it.
<span class="lineNum">    1989 </span><span class="lineNoCov">          0 :       ADD_FAILURE()</span>
<span class="lineNum">    1990 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;All tests in the same test case must use the same test fixture\n&quot;</span>
<span class="lineNum">    1991 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;class.  However, in test case &quot;</span>
<span class="lineNum">    1992 </span><span class="lineNoCov">          0 :           &lt;&lt; this_test_info-&gt;test_case_name() &lt;&lt; &quot;,\n&quot;</span>
<span class="lineNum">    1993 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;you defined test &quot; &lt;&lt; first_test_name</span>
<span class="lineNum">    1994 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot; and test &quot; &lt;&lt; this_test_name &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">    1995 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;using two different test fixture classes.  This can happen if\n&quot;</span>
<span class="lineNum">    1996 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;the two classes are from different namespaces or translation\n&quot;</span>
<span class="lineNum">    1997 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;units and have the same name.  You should probably rename one\n&quot;</span>
<span class="lineNum">    1998 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;of the classes to put the tests into different test cases.&quot;;</span>
<span class="lineNum">    1999 </span>            :     }
<span class="lineNum">    2000 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    2001 </span>            :   }
<span class="lineNum">    2002 </span>            : 
<span class="lineNum">    2003 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    2004 </span>            : }
<span class="lineNum">    2005 </span>            : 
<span class="lineNum">    2006 </span>            : #if GTEST_HAS_SEH
<span class="lineNum">    2007 </span>            : 
<span class="lineNum">    2008 </span>            : // Adds an &quot;exception thrown&quot; fatal failure to the current test.  This
<span class="lineNum">    2009 </span>            : // function returns its result via an output parameter pointer because VC++
<span class="lineNum">    2010 </span>            : // prohibits creation of objects with destructors on stack in functions
<span class="lineNum">    2011 </span>            : // using __try (see error C2712).
<span class="lineNum">    2012 </span>            : static std::string* FormatSehExceptionMessage(DWORD exception_code,
<span class="lineNum">    2013 </span>            :                                               const char* location) {
<span class="lineNum">    2014 </span>            :   Message message;
<span class="lineNum">    2015 </span>            :   message &lt;&lt; &quot;SEH exception with code 0x&quot; &lt;&lt; std::setbase(16) &lt;&lt;
<span class="lineNum">    2016 </span>            :     exception_code &lt;&lt; std::setbase(10) &lt;&lt; &quot; thrown in &quot; &lt;&lt; location &lt;&lt; &quot;.&quot;;
<span class="lineNum">    2017 </span>            : 
<span class="lineNum">    2018 </span>            :   return new std::string(message.GetString());
<span class="lineNum">    2019 </span>            : }
<span class="lineNum">    2020 </span>            : 
<span class="lineNum">    2021 </span>            : #endif  // GTEST_HAS_SEH
<span class="lineNum">    2022 </span>            : 
<span class="lineNum">    2023 </span>            : namespace internal {
<span class="lineNum">    2024 </span>            : 
<span class="lineNum">    2025 </span>            : #if GTEST_HAS_EXCEPTIONS
<a name="2026"><span class="lineNum">    2026 </span>            : </a>
<span class="lineNum">    2027 </span>            : // Adds an &quot;exception thrown&quot; fatal failure to the current test.
<span class="lineNum">    2028 </span><span class="lineNoCov">          0 : static std::string FormatCxxExceptionMessage(const char* description,</span>
<span class="lineNum">    2029 </span>            :                                              const char* location) {
<span class="lineNum">    2030 </span><span class="lineNoCov">          0 :   Message message;</span>
<span class="lineNum">    2031 </span><span class="lineNoCov">          0 :   if (description != NULL) {</span>
<span class="lineNum">    2032 </span><span class="lineNoCov">          0 :     message &lt;&lt; &quot;C++ exception with description \&quot;&quot; &lt;&lt; description &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    2033 </span>            :   } else {
<span class="lineNum">    2034 </span><span class="lineNoCov">          0 :     message &lt;&lt; &quot;Unknown C++ exception&quot;;</span>
<span class="lineNum">    2035 </span>            :   }
<span class="lineNum">    2036 </span><span class="lineNoCov">          0 :   message &lt;&lt; &quot; thrown in &quot; &lt;&lt; location &lt;&lt; &quot;.&quot;;</span>
<span class="lineNum">    2037 </span>            : 
<span class="lineNum">    2038 </span><span class="lineNoCov">          0 :   return message.GetString();</span>
<span class="lineNum">    2039 </span>            : }
<span class="lineNum">    2040 </span>            : 
<span class="lineNum">    2041 </span>            : static std::string PrintTestPartResultToString(
<a name="2042"><span class="lineNum">    2042 </span>            :     const TestPartResult&amp; test_part_result);</a>
<span class="lineNum">    2043 </span>            : 
<span class="lineNum">    2044 </span><span class="lineNoCov">          0 : GoogleTestFailureException::GoogleTestFailureException(</span>
<span class="lineNum">    2045 </span>            :     const TestPartResult&amp; failure)
<span class="lineNum">    2046 </span><span class="lineNoCov">          0 :     : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}</span>
<span class="lineNum">    2047 </span>            : 
<span class="lineNum">    2048 </span>            : #endif  // GTEST_HAS_EXCEPTIONS
<span class="lineNum">    2049 </span>            : 
<span class="lineNum">    2050 </span>            : // We put these helper functions in the internal namespace as IBM's xlC
<span class="lineNum">    2051 </span>            : // compiler rejects the code if they were declared static.
<span class="lineNum">    2052 </span>            : 
<span class="lineNum">    2053 </span>            : // Runs the given method and handles SEH exceptions it throws, when
<span class="lineNum">    2054 </span>            : // SEH is supported; returns the 0-value for type Result in case of an
<span class="lineNum">    2055 </span>            : // SEH exception.  (Microsoft compilers cannot handle SEH and C++
<span class="lineNum">    2056 </span>            : // exceptions in the same function.  Therefore, we provide a separate
<a name="2057"><span class="lineNum">    2057 </span>            : // wrapper function for handling SEH exceptions.)</a>
<span class="lineNum">    2058 </span>            : template &lt;class T, typename Result&gt;
<span class="lineNum">    2059 </span><span class="lineNoCov">          0 : Result HandleSehExceptionsInMethodIfSupported(</span>
<span class="lineNum">    2060 </span>            :     T* object, Result (T::*method)(), const char* location) {
<span class="lineNum">    2061 </span>            : #if GTEST_HAS_SEH
<span class="lineNum">    2062 </span>            :   __try {
<span class="lineNum">    2063 </span>            :     return (object-&gt;*method)();
<span class="lineNum">    2064 </span>            :   } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
<span class="lineNum">    2065 </span>            :       GetExceptionCode())) {
<span class="lineNum">    2066 </span>            :     // We create the exception message on the heap because VC++ prohibits
<span class="lineNum">    2067 </span>            :     // creation of objects with destructors on stack in functions using __try
<span class="lineNum">    2068 </span>            :     // (see error C2712).
<span class="lineNum">    2069 </span>            :     std::string* exception_message = FormatSehExceptionMessage(
<span class="lineNum">    2070 </span>            :         GetExceptionCode(), location);
<span class="lineNum">    2071 </span>            :     internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
<span class="lineNum">    2072 </span>            :                                              *exception_message);
<span class="lineNum">    2073 </span>            :     delete exception_message;
<span class="lineNum">    2074 </span>            :     return static_cast&lt;Result&gt;(0);
<span class="lineNum">    2075 </span>            :   }
<span class="lineNum">    2076 </span>            : #else
<span class="lineNum">    2077 </span>            :   (void)location;
<span class="lineNum">    2078 </span><span class="lineNoCov">          0 :   return (object-&gt;*method)();</span>
<span class="lineNum">    2079 </span>            : #endif  // GTEST_HAS_SEH
<span class="lineNum">    2080 </span>            : }
<span class="lineNum">    2081 </span>            : 
<span class="lineNum">    2082 </span>            : // Runs the given method and catches and reports C++ and/or SEH-style
<span class="lineNum">    2083 </span>            : // exceptions, if they are supported; returns the 0-value for type
<a name="2084"><span class="lineNum">    2084 </span>            : // Result in case of an SEH exception.</a>
<span class="lineNum">    2085 </span>            : template &lt;class T, typename Result&gt;
<span class="lineNum">    2086 </span><span class="lineNoCov">          0 : Result HandleExceptionsInMethodIfSupported(</span>
<span class="lineNum">    2087 </span>            :     T* object, Result (T::*method)(), const char* location) {
<span class="lineNum">    2088 </span>            :   // NOTE: The user code can affect the way in which Google Test handles
<span class="lineNum">    2089 </span>            :   // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
<span class="lineNum">    2090 </span>            :   // RUN_ALL_TESTS() starts. It is technically possible to check the flag
<span class="lineNum">    2091 </span>            :   // after the exception is caught and either report or re-throw the
<span class="lineNum">    2092 </span>            :   // exception based on the flag's value:
<span class="lineNum">    2093 </span>            :   //
<span class="lineNum">    2094 </span>            :   // try {
<span class="lineNum">    2095 </span>            :   //   // Perform the test method.
<span class="lineNum">    2096 </span>            :   // } catch (...) {
<span class="lineNum">    2097 </span>            :   //   if (GTEST_FLAG(catch_exceptions))
<span class="lineNum">    2098 </span>            :   //     // Report the exception as failure.
<span class="lineNum">    2099 </span>            :   //   else
<span class="lineNum">    2100 </span>            :   //     throw;  // Re-throws the original exception.
<span class="lineNum">    2101 </span>            :   // }
<span class="lineNum">    2102 </span>            :   //
<span class="lineNum">    2103 </span>            :   // However, the purpose of this flag is to allow the program to drop into
<span class="lineNum">    2104 </span>            :   // the debugger when the exception is thrown. On most platforms, once the
<span class="lineNum">    2105 </span>            :   // control enters the catch block, the exception origin information is
<span class="lineNum">    2106 </span>            :   // lost and the debugger will stop the program at the point of the
<span class="lineNum">    2107 </span>            :   // re-throw in this function -- instead of at the point of the original
<span class="lineNum">    2108 </span>            :   // throw statement in the code under test.  For this reason, we perform
<span class="lineNum">    2109 </span>            :   // the check early, sacrificing the ability to affect Google Test's
<span class="lineNum">    2110 </span>            :   // exception handling in the method where the exception is thrown.
<span class="lineNum">    2111 </span><span class="lineNoCov">          0 :   if (internal::GetUnitTestImpl()-&gt;catch_exceptions()) {</span>
<span class="lineNum">    2112 </span>            : #if GTEST_HAS_EXCEPTIONS
<span class="lineNum">    2113 </span>            :     try {
<span class="lineNum">    2114 </span><span class="lineNoCov">          0 :       return HandleSehExceptionsInMethodIfSupported(object, method, location);</span>
<span class="lineNum">    2115 </span><span class="lineNoCov">          0 :     } catch (const internal::GoogleTestFailureException&amp;) {  // NOLINT</span>
<span class="lineNum">    2116 </span>            :       // This exception type can only be thrown by a failed Google
<span class="lineNum">    2117 </span>            :       // Test assertion with the intention of letting another testing
<span class="lineNum">    2118 </span>            :       // framework catch it.  Therefore we just re-throw it.
<span class="lineNum">    2119 </span><span class="lineNoCov">          0 :       throw;</span>
<span class="lineNum">    2120 </span><span class="lineNoCov">          0 :     } catch (const std::exception&amp; e) {  // NOLINT</span>
<span class="lineNum">    2121 </span><span class="lineNoCov">          0 :       internal::ReportFailureInUnknownLocation(</span>
<span class="lineNum">    2122 </span>            :           TestPartResult::kFatalFailure,
<span class="lineNum">    2123 </span><span class="lineNoCov">          0 :           FormatCxxExceptionMessage(e.what(), location));</span>
<span class="lineNum">    2124 </span><span class="lineNoCov">          0 :     } catch (...) {  // NOLINT</span>
<span class="lineNum">    2125 </span><span class="lineNoCov">          0 :       internal::ReportFailureInUnknownLocation(</span>
<span class="lineNum">    2126 </span>            :           TestPartResult::kFatalFailure,
<span class="lineNum">    2127 </span>            :           FormatCxxExceptionMessage(NULL, location));
<span class="lineNum">    2128 </span>            :     }
<span class="lineNum">    2129 </span><span class="lineNoCov">          0 :     return static_cast&lt;Result&gt;(0);</span>
<span class="lineNum">    2130 </span>            : #else
<span class="lineNum">    2131 </span>            :     return HandleSehExceptionsInMethodIfSupported(object, method, location);
<span class="lineNum">    2132 </span>            : #endif  // GTEST_HAS_EXCEPTIONS
<span class="lineNum">    2133 </span>            :   } else {
<span class="lineNum">    2134 </span><span class="lineNoCov">          0 :     return (object-&gt;*method)();</span>
<span class="lineNum">    2135 </span>            :   }
<span class="lineNum">    2136 </span>            : }
<span class="lineNum">    2137 </span>            : 
<span class="lineNum">    2138 </span>            : }  // namespace internal
<a name="2139"><span class="lineNum">    2139 </span>            : </a>
<span class="lineNum">    2140 </span>            : // Runs the test and updates the test result.
<span class="lineNum">    2141 </span><span class="lineNoCov">          0 : void Test::Run() {</span>
<span class="lineNum">    2142 </span><span class="lineNoCov">          0 :   if (!HasSameFixtureClass()) return;</span>
<span class="lineNum">    2143 </span>            : 
<span class="lineNum">    2144 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">    2145 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2146 </span><span class="lineNoCov">          0 :   internal::HandleExceptionsInMethodIfSupported(this, &amp;Test::SetUp, &quot;SetUp()&quot;);</span>
<span class="lineNum">    2147 </span>            :   // We will run the test only if SetUp() was successful.
<span class="lineNum">    2148 </span><span class="lineNoCov">          0 :   if (!HasFatalFailure()) {</span>
<span class="lineNum">    2149 </span><span class="lineNoCov">          0 :     impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2150 </span>            :     internal::HandleExceptionsInMethodIfSupported(
<span class="lineNum">    2151 </span><span class="lineNoCov">          0 :         this, &amp;Test::TestBody, &quot;the test body&quot;);</span>
<span class="lineNum">    2152 </span>            :   }
<span class="lineNum">    2153 </span>            : 
<span class="lineNum">    2154 </span>            :   // However, we want to clean up as much as possible.  Hence we will
<span class="lineNum">    2155 </span>            :   // always call TearDown(), even if SetUp() or the test body has
<span class="lineNum">    2156 </span>            :   // failed.
<span class="lineNum">    2157 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2158 </span>            :   internal::HandleExceptionsInMethodIfSupported(
<span class="lineNum">    2159 </span><span class="lineNoCov">          0 :       this, &amp;Test::TearDown, &quot;TearDown()&quot;);</span>
<span class="lineNum">    2160 </span>            : }
<a name="2161"><span class="lineNum">    2161 </span>            : </a>
<span class="lineNum">    2162 </span>            : // Returns true iff the current test has a fatal failure.
<span class="lineNum">    2163 </span><span class="lineNoCov">          0 : bool Test::HasFatalFailure() {</span>
<span class="lineNum">    2164 </span><span class="lineNoCov">          0 :   return internal::GetUnitTestImpl()-&gt;current_test_result()-&gt;HasFatalFailure();</span>
<span class="lineNum">    2165 </span>            : }
<a name="2166"><span class="lineNum">    2166 </span>            : </a>
<span class="lineNum">    2167 </span>            : // Returns true iff the current test has a non-fatal failure.
<span class="lineNum">    2168 </span><span class="lineNoCov">          0 : bool Test::HasNonfatalFailure() {</span>
<span class="lineNum">    2169 </span>            :   return internal::GetUnitTestImpl()-&gt;current_test_result()-&gt;
<span class="lineNum">    2170 </span><span class="lineNoCov">          0 :       HasNonfatalFailure();</span>
<span class="lineNum">    2171 </span>            : }
<span class="lineNum">    2172 </span>            : 
<span class="lineNum">    2173 </span>            : // class TestInfo
<span class="lineNum">    2174 </span>            : 
<a name="2175"><span class="lineNum">    2175 </span>            : // Constructs a TestInfo object. It assumes ownership of the test factory</a>
<span class="lineNum">    2176 </span>            : // object.
<span class="lineNum">    2177 </span><span class="lineNoCov">          0 : TestInfo::TestInfo(const std::string&amp; a_test_case_name,</span>
<span class="lineNum">    2178 </span>            :                    const std::string&amp; a_name,
<span class="lineNum">    2179 </span>            :                    const char* a_type_param,
<span class="lineNum">    2180 </span>            :                    const char* a_value_param,
<span class="lineNum">    2181 </span>            :                    internal::TypeId fixture_class_id,
<span class="lineNum">    2182 </span>            :                    internal::TestFactoryBase* factory)
<span class="lineNum">    2183 </span>            :     : test_case_name_(a_test_case_name),
<span class="lineNum">    2184 </span>            :       name_(a_name),
<span class="lineNum">    2185 </span><span class="lineNoCov">          0 :       type_param_(a_type_param ? new std::string(a_type_param) : NULL),</span>
<span class="lineNum">    2186 </span><span class="lineNoCov">          0 :       value_param_(a_value_param ? new std::string(a_value_param) : NULL),</span>
<span class="lineNum">    2187 </span>            :       fixture_class_id_(fixture_class_id),
<span class="lineNum">    2188 </span>            :       should_run_(false),
<span class="lineNum">    2189 </span>            :       is_disabled_(false),
<span class="lineNum">    2190 </span>            :       matches_filter_(false),
<span class="lineNum">    2191 </span>            :       factory_(factory),
<span class="lineNum">    2192 </span><span class="lineNoCov">          0 :       result_() {}</span>
<a name="2193"><span class="lineNum">    2193 </span>            : </a>
<span class="lineNum">    2194 </span>            : // Destructs a TestInfo object.
<span class="lineNum">    2195 </span><span class="lineNoCov">          0 : TestInfo::~TestInfo() { delete factory_; }</span>
<span class="lineNum">    2196 </span>            : 
<span class="lineNum">    2197 </span>            : namespace internal {
<span class="lineNum">    2198 </span>            : 
<span class="lineNum">    2199 </span>            : // Creates a new TestInfo object and registers it with Google Test;
<span class="lineNum">    2200 </span>            : // returns the created object.
<span class="lineNum">    2201 </span>            : //
<span class="lineNum">    2202 </span>            : // Arguments:
<span class="lineNum">    2203 </span>            : //
<span class="lineNum">    2204 </span>            : //   test_case_name:   name of the test case
<span class="lineNum">    2205 </span>            : //   name:             name of the test
<span class="lineNum">    2206 </span>            : //   type_param:       the name of the test's type parameter, or NULL if
<span class="lineNum">    2207 </span>            : //                     this is not a typed or a type-parameterized test.
<span class="lineNum">    2208 </span>            : //   value_param:      text representation of the test's value parameter,
<span class="lineNum">    2209 </span>            : //                     or NULL if this is not a value-parameterized test.
<span class="lineNum">    2210 </span>            : //   fixture_class_id: ID of the test fixture class
<span class="lineNum">    2211 </span>            : //   set_up_tc:        pointer to the function that sets up the test case
<span class="lineNum">    2212 </span>            : //   tear_down_tc:     pointer to the function that tears down the test case
<span class="lineNum">    2213 </span>            : //   factory:          pointer to the factory that creates a test object.
<a name="2214"><span class="lineNum">    2214 </span>            : //                     The newly created TestInfo instance will assume</a>
<span class="lineNum">    2215 </span>            : //                     ownership of the factory object.
<span class="lineNum">    2216 </span><span class="lineNoCov">          0 : TestInfo* MakeAndRegisterTestInfo(</span>
<span class="lineNum">    2217 </span>            :     const char* test_case_name,
<span class="lineNum">    2218 </span>            :     const char* name,
<span class="lineNum">    2219 </span>            :     const char* type_param,
<span class="lineNum">    2220 </span>            :     const char* value_param,
<span class="lineNum">    2221 </span>            :     TypeId fixture_class_id,
<span class="lineNum">    2222 </span>            :     SetUpTestCaseFunc set_up_tc,
<span class="lineNum">    2223 </span>            :     TearDownTestCaseFunc tear_down_tc,
<span class="lineNum">    2224 </span>            :     TestFactoryBase* factory) {
<span class="lineNum">    2225 </span>            :   TestInfo* const test_info =
<span class="lineNum">    2226 </span>            :       new TestInfo(test_case_name, name, type_param, value_param,
<span class="lineNum">    2227 </span><span class="lineNoCov">          0 :                    fixture_class_id, factory);</span>
<span class="lineNum">    2228 </span><span class="lineNoCov">          0 :   GetUnitTestImpl()-&gt;AddTestInfo(set_up_tc, tear_down_tc, test_info);</span>
<span class="lineNum">    2229 </span><span class="lineNoCov">          0 :   return test_info;</span>
<span class="lineNum">    2230 </span>            : }
<a name="2231"><span class="lineNum">    2231 </span>            : </a>
<span class="lineNum">    2232 </span>            : #if GTEST_HAS_PARAM_TEST
<span class="lineNum">    2233 </span><span class="lineNoCov">          0 : void ReportInvalidTestCaseType(const char* test_case_name,</span>
<span class="lineNum">    2234 </span>            :                                const char* file, int line) {
<span class="lineNum">    2235 </span><span class="lineNoCov">          0 :   Message errors;</span>
<span class="lineNum">    2236 </span>            :   errors
<span class="lineNum">    2237 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Attempted redefinition of test case &quot; &lt;&lt; test_case_name &lt;&lt; &quot;.\n&quot;</span>
<span class="lineNum">    2238 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;All tests in the same test case must use the same test fixture\n&quot;</span>
<span class="lineNum">    2239 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;class.  However, in test case &quot; &lt;&lt; test_case_name &lt;&lt; &quot;, you tried\n&quot;</span>
<span class="lineNum">    2240 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;to define a test using a fixture class different from the one\n&quot;</span>
<span class="lineNum">    2241 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;used earlier. This can happen if the two fixture classes are\n&quot;</span>
<span class="lineNum">    2242 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;from different namespaces and have the same name. You should\n&quot;</span>
<span class="lineNum">    2243 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;probably rename one of the classes to put the tests into different\n&quot;</span>
<span class="lineNum">    2244 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;test cases.&quot;;</span>
<span class="lineNum">    2245 </span>            : 
<span class="lineNum">    2246 </span><span class="lineNoCov">          0 :   fprintf(stderr, &quot;%s %s&quot;, FormatFileLocation(file, line).c_str(),</span>
<span class="lineNum">    2247 </span><span class="lineNoCov">          0 :           errors.GetString().c_str());</span>
<span class="lineNum">    2248 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2249 </span>            : #endif  // GTEST_HAS_PARAM_TEST
<span class="lineNum">    2250 </span>            : 
<span class="lineNum">    2251 </span>            : }  // namespace internal
<span class="lineNum">    2252 </span>            : 
<span class="lineNum">    2253 </span>            : namespace {
<span class="lineNum">    2254 </span>            : 
<span class="lineNum">    2255 </span>            : // A predicate that checks the test name of a TestInfo against a known
<span class="lineNum">    2256 </span>            : // value.
<span class="lineNum">    2257 </span>            : //
<span class="lineNum">    2258 </span>            : // This is used for implementation of the TestCase class only.  We put
<span class="lineNum">    2259 </span>            : // it in the anonymous namespace to prevent polluting the outer
<span class="lineNum">    2260 </span>            : // namespace.
<span class="lineNum">    2261 </span>            : //
<span class="lineNum">    2262 </span>            : // TestNameIs is copyable.
<span class="lineNum">    2263 </span>            : class TestNameIs {
<span class="lineNum">    2264 </span>            :  public:
<span class="lineNum">    2265 </span>            :   // Constructor.
<span class="lineNum">    2266 </span>            :   //
<span class="lineNum">    2267 </span>            :   // TestNameIs has NO default constructor.
<span class="lineNum">    2268 </span>            :   explicit TestNameIs(const char* name)
<span class="lineNum">    2269 </span>            :       : name_(name) {}
<span class="lineNum">    2270 </span>            : 
<span class="lineNum">    2271 </span>            :   // Returns true iff the test name of test_info matches name_.
<span class="lineNum">    2272 </span>            :   bool operator()(const TestInfo * test_info) const {
<span class="lineNum">    2273 </span>            :     return test_info &amp;&amp; test_info-&gt;name() == name_;
<span class="lineNum">    2274 </span>            :   }
<span class="lineNum">    2275 </span>            : 
<span class="lineNum">    2276 </span>            :  private:
<span class="lineNum">    2277 </span>            :   std::string name_;
<span class="lineNum">    2278 </span>            : };
<span class="lineNum">    2279 </span>            : 
<span class="lineNum">    2280 </span>            : }  // namespace
<span class="lineNum">    2281 </span>            : 
<span class="lineNum">    2282 </span>            : namespace internal {
<span class="lineNum">    2283 </span>            : 
<span class="lineNum">    2284 </span>            : // This method expands all parameterized tests registered with macros TEST_P
<a name="2285"><span class="lineNum">    2285 </span>            : // and INSTANTIATE_TEST_CASE_P into regular tests and registers those.</a>
<span class="lineNum">    2286 </span>            : // This will be done just once during the program runtime.
<span class="lineNum">    2287 </span><span class="lineNoCov">          0 : void UnitTestImpl::RegisterParameterizedTests() {</span>
<span class="lineNum">    2288 </span>            : #if GTEST_HAS_PARAM_TEST
<span class="lineNum">    2289 </span><span class="lineNoCov">          0 :   if (!parameterized_tests_registered_) {</span>
<span class="lineNum">    2290 </span><span class="lineNoCov">          0 :     parameterized_test_registry_.RegisterTests();</span>
<span class="lineNum">    2291 </span><span class="lineNoCov">          0 :     parameterized_tests_registered_ = true;</span>
<span class="lineNum">    2292 </span>            :   }
<span class="lineNum">    2293 </span>            : #endif
<span class="lineNum">    2294 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2295 </span>            : 
<span class="lineNum">    2296 </span>            : }  // namespace internal
<span class="lineNum">    2297 </span>            : 
<a name="2298"><span class="lineNum">    2298 </span>            : // Creates the test object, runs it, records its result, and then</a>
<span class="lineNum">    2299 </span>            : // deletes it.
<span class="lineNum">    2300 </span><span class="lineNoCov">          0 : void TestInfo::Run() {</span>
<span class="lineNum">    2301 </span><span class="lineNoCov">          0 :   if (!should_run_) return;</span>
<span class="lineNum">    2302 </span>            : 
<span class="lineNum">    2303 </span>            :   // Tells UnitTest where to store test result.
<span class="lineNum">    2304 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">    2305 </span><span class="lineNoCov">          0 :   impl-&gt;set_current_test_info(this);</span>
<span class="lineNum">    2306 </span>            : 
<span class="lineNum">    2307 </span><span class="lineNoCov">          0 :   TestEventListener* repeater = UnitTest::GetInstance()-&gt;listeners().repeater();</span>
<span class="lineNum">    2308 </span>            : 
<span class="lineNum">    2309 </span>            :   // Notifies the unit test event listeners that a test is about to start.
<span class="lineNum">    2310 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestStart(*this);</span>
<span class="lineNum">    2311 </span>            : 
<span class="lineNum">    2312 </span><span class="lineNoCov">          0 :   const TimeInMillis start = internal::GetTimeInMillis();</span>
<span class="lineNum">    2313 </span>            : 
<span class="lineNum">    2314 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2315 </span>            : 
<span class="lineNum">    2316 </span>            :   // Creates the test object.
<span class="lineNum">    2317 </span><span class="lineNoCov">          0 :   Test* const test = internal::HandleExceptionsInMethodIfSupported(</span>
<span class="lineNum">    2318 </span><span class="lineNoCov">          0 :       factory_, &amp;internal::TestFactoryBase::CreateTest,</span>
<span class="lineNum">    2319 </span><span class="lineNoCov">          0 :       &quot;the test fixture's constructor&quot;);</span>
<span class="lineNum">    2320 </span>            : 
<span class="lineNum">    2321 </span>            :   // Runs the test only if the test object was created and its
<span class="lineNum">    2322 </span>            :   // constructor didn't generate a fatal failure.
<span class="lineNum">    2323 </span><span class="lineNoCov">          0 :   if ((test != NULL) &amp;&amp; !Test::HasFatalFailure()) {</span>
<span class="lineNum">    2324 </span>            :     // This doesn't throw as all user code that can throw are wrapped into
<span class="lineNum">    2325 </span>            :     // exception handling code.
<span class="lineNum">    2326 </span><span class="lineNoCov">          0 :     test-&gt;Run();</span>
<span class="lineNum">    2327 </span>            :   }
<span class="lineNum">    2328 </span>            : 
<span class="lineNum">    2329 </span>            :   // Deletes the test object.
<span class="lineNum">    2330 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2331 </span>            :   internal::HandleExceptionsInMethodIfSupported(
<span class="lineNum">    2332 </span><span class="lineNoCov">          0 :       test, &amp;Test::DeleteSelf_, &quot;the test fixture's destructor&quot;);</span>
<span class="lineNum">    2333 </span>            : 
<span class="lineNum">    2334 </span><span class="lineNoCov">          0 :   result_.set_elapsed_time(internal::GetTimeInMillis() - start);</span>
<span class="lineNum">    2335 </span>            : 
<span class="lineNum">    2336 </span>            :   // Notifies the unit test event listener that a test has just finished.
<span class="lineNum">    2337 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestEnd(*this);</span>
<span class="lineNum">    2338 </span>            : 
<span class="lineNum">    2339 </span>            :   // Tells UnitTest to stop associating assertion results to this
<span class="lineNum">    2340 </span>            :   // test.
<span class="lineNum">    2341 </span><span class="lineNoCov">          0 :   impl-&gt;set_current_test_info(NULL);</span>
<span class="lineNum">    2342 </span>            : }
<span class="lineNum">    2343 </span>            : 
<span class="lineNum">    2344 </span>            : // class TestCase
<a name="2345"><span class="lineNum">    2345 </span>            : </a>
<span class="lineNum">    2346 </span>            : // Gets the number of successful tests in this test case.
<span class="lineNum">    2347 </span><span class="lineNoCov">          0 : int TestCase::successful_test_count() const {</span>
<span class="lineNum">    2348 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, TestPassed);</span>
<span class="lineNum">    2349 </span>            : }
<a name="2350"><span class="lineNum">    2350 </span>            : </a>
<span class="lineNum">    2351 </span>            : // Gets the number of failed tests in this test case.
<span class="lineNum">    2352 </span><span class="lineNoCov">          0 : int TestCase::failed_test_count() const {</span>
<span class="lineNum">    2353 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, TestFailed);</span>
<span class="lineNum">    2354 </span>            : }
<a name="2355"><span class="lineNum">    2355 </span>            : </a>
<span class="lineNum">    2356 </span>            : // Gets the number of disabled tests that will be reported in the XML report.
<span class="lineNum">    2357 </span><span class="lineNoCov">          0 : int TestCase::reportable_disabled_test_count() const {</span>
<span class="lineNum">    2358 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, TestReportableDisabled);</span>
<span class="lineNum">    2359 </span>            : }
<a name="2360"><span class="lineNum">    2360 </span>            : </a>
<span class="lineNum">    2361 </span>            : // Gets the number of disabled tests in this test case.
<span class="lineNum">    2362 </span><span class="lineNoCov">          0 : int TestCase::disabled_test_count() const {</span>
<span class="lineNum">    2363 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, TestDisabled);</span>
<span class="lineNum">    2364 </span>            : }
<a name="2365"><span class="lineNum">    2365 </span>            : </a>
<span class="lineNum">    2366 </span>            : // Gets the number of tests to be printed in the XML report.
<span class="lineNum">    2367 </span><span class="lineNoCov">          0 : int TestCase::reportable_test_count() const {</span>
<span class="lineNum">    2368 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, TestReportable);</span>
<span class="lineNum">    2369 </span>            : }
<a name="2370"><span class="lineNum">    2370 </span>            : </a>
<span class="lineNum">    2371 </span>            : // Get the number of tests in this test case that should run.
<span class="lineNum">    2372 </span><span class="lineNoCov">          0 : int TestCase::test_to_run_count() const {</span>
<span class="lineNum">    2373 </span><span class="lineNoCov">          0 :   return CountIf(test_info_list_, ShouldRunTest);</span>
<span class="lineNum">    2374 </span>            : }
<a name="2375"><span class="lineNum">    2375 </span>            : </a>
<span class="lineNum">    2376 </span>            : // Gets the number of all tests.
<span class="lineNum">    2377 </span><span class="lineNoCov">          0 : int TestCase::total_test_count() const {</span>
<span class="lineNum">    2378 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(test_info_list_.size());</span>
<span class="lineNum">    2379 </span>            : }
<span class="lineNum">    2380 </span>            : 
<span class="lineNum">    2381 </span>            : // Creates a TestCase with the given name.
<span class="lineNum">    2382 </span>            : //
<span class="lineNum">    2383 </span>            : // Arguments:
<span class="lineNum">    2384 </span>            : //
<span class="lineNum">    2385 </span>            : //   name:         name of the test case
<span class="lineNum">    2386 </span>            : //   a_type_param: the name of the test case's type parameter, or NULL if
<span class="lineNum">    2387 </span>            : //                 this is not a typed or a type-parameterized test case.
<a name="2388"><span class="lineNum">    2388 </span>            : //   set_up_tc:    pointer to the function that sets up the test case</a>
<span class="lineNum">    2389 </span>            : //   tear_down_tc: pointer to the function that tears down the test case
<span class="lineNum">    2390 </span><span class="lineNoCov">          0 : TestCase::TestCase(const char* a_name, const char* a_type_param,</span>
<span class="lineNum">    2391 </span>            :                    Test::SetUpTestCaseFunc set_up_tc,
<span class="lineNum">    2392 </span>            :                    Test::TearDownTestCaseFunc tear_down_tc)
<span class="lineNum">    2393 </span>            :     : name_(a_name),
<span class="lineNum">    2394 </span><span class="lineNoCov">          0 :       type_param_(a_type_param ? new std::string(a_type_param) : NULL),</span>
<span class="lineNum">    2395 </span>            :       set_up_tc_(set_up_tc),
<span class="lineNum">    2396 </span>            :       tear_down_tc_(tear_down_tc),
<span class="lineNum">    2397 </span>            :       should_run_(false),
<span class="lineNum">    2398 </span><span class="lineNoCov">          0 :       elapsed_time_(0) {</span>
<span class="lineNum">    2399 </span><span class="lineNoCov">          0 : }</span>
<a name="2400"><span class="lineNum">    2400 </span>            : </a>
<span class="lineNum">    2401 </span>            : // Destructor of TestCase.
<span class="lineNum">    2402 </span><span class="lineNoCov">          0 : TestCase::~TestCase() {</span>
<span class="lineNum">    2403 </span>            :   // Deletes every Test in the collection.
<span class="lineNum">    2404 </span><span class="lineNoCov">          0 :   ForEach(test_info_list_, internal::Delete&lt;TestInfo&gt;);</span>
<span class="lineNum">    2405 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2406 </span>            : 
<a name="2407"><span class="lineNum">    2407 </span>            : // Returns the i-th test among all the tests. i can range from 0 to</a>
<span class="lineNum">    2408 </span>            : // total_test_count() - 1. If i is not in that range, returns NULL.
<span class="lineNum">    2409 </span><span class="lineNoCov">          0 : const TestInfo* TestCase::GetTestInfo(int i) const {</span>
<span class="lineNum">    2410 </span><span class="lineNoCov">          0 :   const int index = GetElementOr(test_indices_, i, -1);</span>
<span class="lineNum">    2411 </span><span class="lineNoCov">          0 :   return index &lt; 0 ? NULL : test_info_list_[index];</span>
<span class="lineNum">    2412 </span>            : }
<span class="lineNum">    2413 </span>            : 
<a name="2414"><span class="lineNum">    2414 </span>            : // Returns the i-th test among all the tests. i can range from 0 to</a>
<span class="lineNum">    2415 </span>            : // total_test_count() - 1. If i is not in that range, returns NULL.
<span class="lineNum">    2416 </span><span class="lineNoCov">          0 : TestInfo* TestCase::GetMutableTestInfo(int i) {</span>
<span class="lineNum">    2417 </span><span class="lineNoCov">          0 :   const int index = GetElementOr(test_indices_, i, -1);</span>
<span class="lineNum">    2418 </span><span class="lineNoCov">          0 :   return index &lt; 0 ? NULL : test_info_list_[index];</span>
<span class="lineNum">    2419 </span>            : }
<span class="lineNum">    2420 </span>            : 
<a name="2421"><span class="lineNum">    2421 </span>            : // Adds a test to this test case.  Will delete the test upon</a>
<span class="lineNum">    2422 </span>            : // destruction of the TestCase object.
<span class="lineNum">    2423 </span><span class="lineNoCov">          0 : void TestCase::AddTestInfo(TestInfo * test_info) {</span>
<span class="lineNum">    2424 </span><span class="lineNoCov">          0 :   test_info_list_.push_back(test_info);</span>
<span class="lineNum">    2425 </span><span class="lineNoCov">          0 :   test_indices_.push_back(static_cast&lt;int&gt;(test_indices_.size()));</span>
<span class="lineNum">    2426 </span><span class="lineNoCov">          0 : }</span>
<a name="2427"><span class="lineNum">    2427 </span>            : </a>
<span class="lineNum">    2428 </span>            : // Runs every test in this TestCase.
<span class="lineNum">    2429 </span><span class="lineNoCov">          0 : void TestCase::Run() {</span>
<span class="lineNum">    2430 </span><span class="lineNoCov">          0 :   if (!should_run_) return;</span>
<span class="lineNum">    2431 </span>            : 
<span class="lineNum">    2432 </span><span class="lineNoCov">          0 :   internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();</span>
<span class="lineNum">    2433 </span><span class="lineNoCov">          0 :   impl-&gt;set_current_test_case(this);</span>
<span class="lineNum">    2434 </span>            : 
<span class="lineNum">    2435 </span><span class="lineNoCov">          0 :   TestEventListener* repeater = UnitTest::GetInstance()-&gt;listeners().repeater();</span>
<span class="lineNum">    2436 </span>            : 
<span class="lineNum">    2437 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestCaseStart(*this);</span>
<span class="lineNum">    2438 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2439 </span>            :   internal::HandleExceptionsInMethodIfSupported(
<span class="lineNum">    2440 </span><span class="lineNoCov">          0 :       this, &amp;TestCase::RunSetUpTestCase, &quot;SetUpTestCase()&quot;);</span>
<span class="lineNum">    2441 </span>            : 
<span class="lineNum">    2442 </span><span class="lineNoCov">          0 :   const internal::TimeInMillis start = internal::GetTimeInMillis();</span>
<span class="lineNum">    2443 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; total_test_count(); i++) {</span>
<span class="lineNum">    2444 </span><span class="lineNoCov">          0 :     GetMutableTestInfo(i)-&gt;Run();</span>
<span class="lineNum">    2445 </span>            :   }
<span class="lineNum">    2446 </span><span class="lineNoCov">          0 :   elapsed_time_ = internal::GetTimeInMillis() - start;</span>
<span class="lineNum">    2447 </span>            : 
<span class="lineNum">    2448 </span><span class="lineNoCov">          0 :   impl-&gt;os_stack_trace_getter()-&gt;UponLeavingGTest();</span>
<span class="lineNum">    2449 </span>            :   internal::HandleExceptionsInMethodIfSupported(
<span class="lineNum">    2450 </span><span class="lineNoCov">          0 :       this, &amp;TestCase::RunTearDownTestCase, &quot;TearDownTestCase()&quot;);</span>
<span class="lineNum">    2451 </span>            : 
<span class="lineNum">    2452 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestCaseEnd(*this);</span>
<span class="lineNum">    2453 </span><span class="lineNoCov">          0 :   impl-&gt;set_current_test_case(NULL);</span>
<span class="lineNum">    2454 </span>            : }
<a name="2455"><span class="lineNum">    2455 </span>            : </a>
<span class="lineNum">    2456 </span>            : // Clears the results of all tests in this test case.
<span class="lineNum">    2457 </span><span class="lineNoCov">          0 : void TestCase::ClearResult() {</span>
<span class="lineNum">    2458 </span><span class="lineNoCov">          0 :   ad_hoc_test_result_.Clear();</span>
<span class="lineNum">    2459 </span><span class="lineNoCov">          0 :   ForEach(test_info_list_, TestInfo::ClearTestResult);</span>
<span class="lineNum">    2460 </span><span class="lineNoCov">          0 : }</span>
<a name="2461"><span class="lineNum">    2461 </span>            : </a>
<span class="lineNum">    2462 </span>            : // Shuffles the tests in this test case.
<span class="lineNum">    2463 </span><span class="lineNoCov">          0 : void TestCase::ShuffleTests(internal::Random* random) {</span>
<span class="lineNum">    2464 </span><span class="lineNoCov">          0 :   Shuffle(random, &amp;test_indices_);</span>
<span class="lineNum">    2465 </span><span class="lineNoCov">          0 : }</span>
<a name="2466"><span class="lineNum">    2466 </span>            : </a>
<span class="lineNum">    2467 </span>            : // Restores the test order to before the first shuffle.
<span class="lineNum">    2468 </span><span class="lineNoCov">          0 : void TestCase::UnshuffleTests() {</span>
<span class="lineNum">    2469 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; test_indices_.size(); i++) {</span>
<span class="lineNum">    2470 </span><span class="lineNoCov">          0 :     test_indices_[i] = static_cast&lt;int&gt;(i);</span>
<span class="lineNum">    2471 </span>            :   }
<span class="lineNum">    2472 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2473 </span>            : 
<span class="lineNum">    2474 </span>            : // Formats a countable noun.  Depending on its quantity, either the
<span class="lineNum">    2475 </span>            : // singular form or the plural form is used. e.g.
<span class="lineNum">    2476 </span>            : //
<a name="2477"><span class="lineNum">    2477 </span>            : // FormatCountableNoun(1, &quot;formula&quot;, &quot;formuli&quot;) returns &quot;1 formula&quot;.</a>
<span class="lineNum">    2478 </span>            : // FormatCountableNoun(5, &quot;book&quot;, &quot;books&quot;) returns &quot;5 books&quot;.
<span class="lineNum">    2479 </span><span class="lineNoCov">          0 : static std::string FormatCountableNoun(int count,</span>
<span class="lineNum">    2480 </span>            :                                        const char * singular_form,
<span class="lineNum">    2481 </span>            :                                        const char * plural_form) {
<span class="lineNum">    2482 </span><span class="lineNoCov">          0 :   return internal::StreamableToString(count) + &quot; &quot; +</span>
<span class="lineNum">    2483 </span><span class="lineNoCov">          0 :       (count == 1 ? singular_form : plural_form);</span>
<span class="lineNum">    2484 </span>            : }
<a name="2485"><span class="lineNum">    2485 </span>            : </a>
<span class="lineNum">    2486 </span>            : // Formats the count of tests.
<span class="lineNum">    2487 </span><span class="lineNoCov">          0 : static std::string FormatTestCount(int test_count) {</span>
<span class="lineNum">    2488 </span><span class="lineNoCov">          0 :   return FormatCountableNoun(test_count, &quot;test&quot;, &quot;tests&quot;);</span>
<span class="lineNum">    2489 </span>            : }
<a name="2490"><span class="lineNum">    2490 </span>            : </a>
<span class="lineNum">    2491 </span>            : // Formats the count of test cases.
<span class="lineNum">    2492 </span><span class="lineNoCov">          0 : static std::string FormatTestCaseCount(int test_case_count) {</span>
<span class="lineNum">    2493 </span><span class="lineNoCov">          0 :   return FormatCountableNoun(test_case_count, &quot;test case&quot;, &quot;test cases&quot;);</span>
<span class="lineNum">    2494 </span>            : }
<span class="lineNum">    2495 </span>            : 
<span class="lineNum">    2496 </span>            : // Converts a TestPartResult::Type enum to human-friendly string
<span class="lineNum">    2497 </span>            : // representation.  Both kNonFatalFailure and kFatalFailure are translated
<a name="2498"><span class="lineNum">    2498 </span>            : // to &quot;Failure&quot;, as the user usually doesn't care about the difference</a>
<span class="lineNum">    2499 </span>            : // between the two when viewing the test result.
<span class="lineNum">    2500 </span><span class="lineNoCov">          0 : static const char * TestPartResultTypeToString(TestPartResult::Type type) {</span>
<span class="lineNum">    2501 </span><span class="lineNoCov">          0 :   switch (type) {</span>
<span class="lineNum">    2502 </span>            :     case TestPartResult::kSuccess:
<span class="lineNum">    2503 </span><span class="lineNoCov">          0 :       return &quot;Success&quot;;</span>
<span class="lineNum">    2504 </span>            : 
<span class="lineNum">    2505 </span>            :     case TestPartResult::kNonFatalFailure:
<span class="lineNum">    2506 </span>            :     case TestPartResult::kFatalFailure:
<span class="lineNum">    2507 </span>            : #ifdef _MSC_VER
<span class="lineNum">    2508 </span>            :       return &quot;error: &quot;;
<span class="lineNum">    2509 </span>            : #else
<span class="lineNum">    2510 </span><span class="lineNoCov">          0 :       return &quot;Failure\n&quot;;</span>
<span class="lineNum">    2511 </span>            : #endif
<span class="lineNum">    2512 </span>            :     default:
<span class="lineNum">    2513 </span><span class="lineNoCov">          0 :       return &quot;Unknown result type&quot;;</span>
<span class="lineNum">    2514 </span>            :   }
<span class="lineNum">    2515 </span>            : }
<span class="lineNum">    2516 </span>            : 
<span class="lineNum">    2517 </span>            : namespace internal {
<a name="2518"><span class="lineNum">    2518 </span>            : </a>
<span class="lineNum">    2519 </span>            : // Prints a TestPartResult to an std::string.
<span class="lineNum">    2520 </span><span class="lineNoCov">          0 : static std::string PrintTestPartResultToString(</span>
<span class="lineNum">    2521 </span>            :     const TestPartResult&amp; test_part_result) {
<span class="lineNum">    2522 </span>            :   return (Message()
<span class="lineNum">    2523 </span><span class="lineNoCov">          0 :           &lt;&lt; internal::FormatFileLocation(test_part_result.file_name(),</span>
<span class="lineNum">    2524 </span><span class="lineNoCov">          0 :                                           test_part_result.line_number())</span>
<span class="lineNum">    2525 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot; &quot; &lt;&lt; TestPartResultTypeToString(test_part_result.type())</span>
<span class="lineNum">    2526 </span><span class="lineNoCov">          0 :           &lt;&lt; test_part_result.message()).GetString();</span>
<span class="lineNum">    2527 </span>            : }
<a name="2528"><span class="lineNum">    2528 </span>            : </a>
<span class="lineNum">    2529 </span>            : // Prints a TestPartResult.
<span class="lineNum">    2530 </span><span class="lineNoCov">          0 : static void PrintTestPartResult(const TestPartResult&amp; test_part_result) {</span>
<span class="lineNum">    2531 </span>            :   const std::string&amp; result =
<span class="lineNum">    2532 </span><span class="lineNoCov">          0 :       PrintTestPartResultToString(test_part_result);</span>
<span class="lineNum">    2533 </span><span class="lineNoCov">          0 :   printf(&quot;%s\n&quot;, result.c_str());</span>
<span class="lineNum">    2534 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<span class="lineNum">    2535 </span>            :   // If the test program runs in Visual Studio or a debugger, the
<span class="lineNum">    2536 </span>            :   // following statements add the test part result message to the Output
<span class="lineNum">    2537 </span>            :   // window such that the user can double-click on it to jump to the
<span class="lineNum">    2538 </span>            :   // corresponding source code location; otherwise they do nothing.
<span class="lineNum">    2539 </span>            : #if GTEST_OS_WINDOWS &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    2540 </span>            :   // We don't call OutputDebugString*() on Windows Mobile, as printing
<span class="lineNum">    2541 </span>            :   // to stdout is done by OutputDebugString() there already - we don't
<span class="lineNum">    2542 </span>            :   // want the same message printed twice.
<span class="lineNum">    2543 </span>            :   ::OutputDebugStringA(result.c_str());
<span class="lineNum">    2544 </span>            :   ::OutputDebugStringA(&quot;\n&quot;);
<span class="lineNum">    2545 </span>            : #endif
<span class="lineNum">    2546 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2547 </span>            : 
<span class="lineNum">    2548 </span>            : // class PrettyUnitTestResultPrinter
<span class="lineNum">    2549 </span>            : 
<span class="lineNum">    2550 </span>            : enum GTestColor {
<span class="lineNum">    2551 </span>            :   COLOR_DEFAULT,
<span class="lineNum">    2552 </span>            :   COLOR_RED,
<span class="lineNum">    2553 </span>            :   COLOR_GREEN,
<span class="lineNum">    2554 </span>            :   COLOR_YELLOW
<span class="lineNum">    2555 </span>            : };
<span class="lineNum">    2556 </span>            : 
<span class="lineNum">    2557 </span>            : #if GTEST_OS_WINDOWS &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    2558 </span>            : 
<span class="lineNum">    2559 </span>            : // Returns the character attribute for the given color.
<span class="lineNum">    2560 </span>            : WORD GetColorAttribute(GTestColor color) {
<span class="lineNum">    2561 </span>            :   switch (color) {
<span class="lineNum">    2562 </span>            :     case COLOR_RED:    return FOREGROUND_RED;
<span class="lineNum">    2563 </span>            :     case COLOR_GREEN:  return FOREGROUND_GREEN;
<span class="lineNum">    2564 </span>            :     case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
<span class="lineNum">    2565 </span>            :     default:           return 0;
<span class="lineNum">    2566 </span>            :   }
<span class="lineNum">    2567 </span>            : }
<span class="lineNum">    2568 </span>            : 
<span class="lineNum">    2569 </span>            : #else
<span class="lineNum">    2570 </span>            : 
<a name="2571"><span class="lineNum">    2571 </span>            : // Returns the ANSI color code for the given color.  COLOR_DEFAULT is</a>
<span class="lineNum">    2572 </span>            : // an invalid input.
<span class="lineNum">    2573 </span><span class="lineNoCov">          0 : const char* GetAnsiColorCode(GTestColor color) {</span>
<span class="lineNum">    2574 </span><span class="lineNoCov">          0 :   switch (color) {</span>
<span class="lineNum">    2575 </span><span class="lineNoCov">          0 :     case COLOR_RED:     return &quot;1&quot;;</span>
<span class="lineNum">    2576 </span><span class="lineNoCov">          0 :     case COLOR_GREEN:   return &quot;2&quot;;</span>
<span class="lineNum">    2577 </span><span class="lineNoCov">          0 :     case COLOR_YELLOW:  return &quot;3&quot;;</span>
<span class="lineNum">    2578 </span><span class="lineNoCov">          0 :     default:            return NULL;</span>
<span class="lineNum">    2579 </span>            :   };
<span class="lineNum">    2580 </span>            : }
<span class="lineNum">    2581 </span>            : 
<span class="lineNum">    2582 </span>            : #endif  // GTEST_OS_WINDOWS &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<a name="2583"><span class="lineNum">    2583 </span>            : </a>
<span class="lineNum">    2584 </span>            : // Returns true iff Google Test should use colors in the output.
<span class="lineNum">    2585 </span><span class="lineNoCov">          0 : bool ShouldUseColor(bool stdout_is_tty) {</span>
<span class="lineNum">    2586 </span><span class="lineNoCov">          0 :   const char* const gtest_color = GTEST_FLAG(color).c_str();</span>
<span class="lineNum">    2587 </span>            : 
<span class="lineNum">    2588 </span><span class="lineNoCov">          0 :   if (String::CaseInsensitiveCStringEquals(gtest_color, &quot;auto&quot;)) {</span>
<span class="lineNum">    2589 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    2590 </span>            :     // On Windows the TERM variable is usually not set, but the
<span class="lineNum">    2591 </span>            :     // console there does support colors.
<span class="lineNum">    2592 </span>            :     return stdout_is_tty;
<span class="lineNum">    2593 </span>            : #else
<span class="lineNum">    2594 </span>            :     // On non-Windows platforms, we rely on the TERM variable.
<span class="lineNum">    2595 </span><span class="lineNoCov">          0 :     const char* const term = posix::GetEnv(&quot;TERM&quot;);</span>
<span class="lineNum">    2596 </span>            :     const bool term_supports_color =
<span class="lineNum">    2597 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;xterm&quot;) ||</span>
<span class="lineNum">    2598 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;xterm-color&quot;) ||</span>
<span class="lineNum">    2599 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;xterm-256color&quot;) ||</span>
<span class="lineNum">    2600 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;screen&quot;) ||</span>
<span class="lineNum">    2601 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;screen-256color&quot;) ||</span>
<span class="lineNum">    2602 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;linux&quot;) ||</span>
<span class="lineNum">    2603 </span><span class="lineNoCov">          0 :         String::CStringEquals(term, &quot;cygwin&quot;);</span>
<span class="lineNum">    2604 </span><span class="lineNoCov">          0 :     return stdout_is_tty &amp;&amp; term_supports_color;</span>
<span class="lineNum">    2605 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    2606 </span>            :   }
<span class="lineNum">    2607 </span>            : 
<span class="lineNum">    2608 </span><span class="lineNoCov">          0 :   return String::CaseInsensitiveCStringEquals(gtest_color, &quot;yes&quot;) ||</span>
<span class="lineNum">    2609 </span><span class="lineNoCov">          0 :       String::CaseInsensitiveCStringEquals(gtest_color, &quot;true&quot;) ||</span>
<span class="lineNum">    2610 </span><span class="lineNoCov">          0 :       String::CaseInsensitiveCStringEquals(gtest_color, &quot;t&quot;) ||</span>
<span class="lineNum">    2611 </span><span class="lineNoCov">          0 :       String::CStringEquals(gtest_color, &quot;1&quot;);</span>
<span class="lineNum">    2612 </span>            :   // We take &quot;yes&quot;, &quot;true&quot;, &quot;t&quot;, and &quot;1&quot; as meaning &quot;yes&quot;.  If the
<span class="lineNum">    2613 </span>            :   // value is neither one of these nor &quot;auto&quot;, we treat it as &quot;no&quot; to
<span class="lineNum">    2614 </span>            :   // be conservative.
<span class="lineNum">    2615 </span>            : }
<span class="lineNum">    2616 </span>            : 
<span class="lineNum">    2617 </span>            : // Helpers for printing colored strings to stdout. Note that on Windows, we
<span class="lineNum">    2618 </span>            : // cannot simply emit special characters and have the terminal change colors.
<a name="2619"><span class="lineNum">    2619 </span>            : // This routine must actually emit the characters rather than return a string</a>
<span class="lineNum">    2620 </span>            : // that would be colored when printed, as can be done on Linux.
<span class="lineNum">    2621 </span><span class="lineNoCov">          0 : void ColoredPrintf(GTestColor color, const char* fmt, ...) {</span>
<span class="lineNum">    2622 </span>            :   va_list args;
<span class="lineNum">    2623 </span><span class="lineNoCov">          0 :   va_start(args, fmt);</span>
<span class="lineNum">    2624 </span>            : 
<span class="lineNum">    2625 </span>            : #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS
<span class="lineNum">    2626 </span>            :   const bool use_color = false;
<span class="lineNum">    2627 </span>            : #else
<span class="lineNum">    2628 </span>            :   static const bool in_color_mode =
<span class="lineNum">    2629 </span><span class="lineNoCov">          0 :       ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);</span>
<span class="lineNum">    2630 </span><span class="lineNoCov">          0 :   const bool use_color = in_color_mode &amp;&amp; (color != COLOR_DEFAULT);</span>
<span class="lineNum">    2631 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
<span class="lineNum">    2632 </span>            :   // The '!= 0' comparison is necessary to satisfy MSVC 7.1.
<span class="lineNum">    2633 </span>            : 
<span class="lineNum">    2634 </span><span class="lineNoCov">          0 :   if (!use_color) {</span>
<span class="lineNum">    2635 </span><span class="lineNoCov">          0 :     vprintf(fmt, args);</span>
<span class="lineNum">    2636 </span><span class="lineNoCov">          0 :     va_end(args);</span>
<span class="lineNum">    2637 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">    2638 </span>            :   }
<span class="lineNum">    2639 </span>            : 
<span class="lineNum">    2640 </span>            : #if GTEST_OS_WINDOWS &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    2641 </span>            :   const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
<span class="lineNum">    2642 </span>            : 
<span class="lineNum">    2643 </span>            :   // Gets the current text color.
<span class="lineNum">    2644 </span>            :   CONSOLE_SCREEN_BUFFER_INFO buffer_info;
<span class="lineNum">    2645 </span>            :   GetConsoleScreenBufferInfo(stdout_handle, &amp;buffer_info);
<span class="lineNum">    2646 </span>            :   const WORD old_color_attrs = buffer_info.wAttributes;
<span class="lineNum">    2647 </span>            : 
<span class="lineNum">    2648 </span>            :   // We need to flush the stream buffers into the console before each
<span class="lineNum">    2649 </span>            :   // SetConsoleTextAttribute call lest it affect the text that is already
<span class="lineNum">    2650 </span>            :   // printed but has not yet reached the console.
<span class="lineNum">    2651 </span>            :   fflush(stdout);
<span class="lineNum">    2652 </span>            :   SetConsoleTextAttribute(stdout_handle,
<span class="lineNum">    2653 </span>            :                           GetColorAttribute(color) | FOREGROUND_INTENSITY);
<span class="lineNum">    2654 </span>            :   vprintf(fmt, args);
<span class="lineNum">    2655 </span>            : 
<span class="lineNum">    2656 </span>            :   fflush(stdout);
<span class="lineNum">    2657 </span>            :   // Restores the text color.
<span class="lineNum">    2658 </span>            :   SetConsoleTextAttribute(stdout_handle, old_color_attrs);
<span class="lineNum">    2659 </span>            : #else
<span class="lineNum">    2660 </span><span class="lineNoCov">          0 :   printf(&quot;\033[0;3%sm&quot;, GetAnsiColorCode(color));</span>
<span class="lineNum">    2661 </span><span class="lineNoCov">          0 :   vprintf(fmt, args);</span>
<span class="lineNum">    2662 </span><span class="lineNoCov">          0 :   printf(&quot;\033[m&quot;);  // Resets the terminal to default.</span>
<span class="lineNum">    2663 </span>            : #endif  // GTEST_OS_WINDOWS &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    2664 </span><span class="lineNoCov">          0 :   va_end(args);</span>
<span class="lineNum">    2665 </span>            : }
<span class="lineNum">    2666 </span>            : 
<span class="lineNum">    2667 </span>            : // Text printed in Google Test's text output and --gunit_list_tests
<span class="lineNum">    2668 </span>            : // output to label the type parameter and value parameter for a test.
<span class="lineNum">    2669 </span>            : static const char kTypeParamLabel[] = &quot;TypeParam&quot;;
<a name="2670"><span class="lineNum">    2670 </span>            : static const char kValueParamLabel[] = &quot;GetParam()&quot;;</a>
<span class="lineNum">    2671 </span>            : 
<span class="lineNum">    2672 </span><span class="lineNoCov">          0 : void PrintFullTestCommentIfPresent(const TestInfo&amp; test_info) {</span>
<span class="lineNum">    2673 </span><span class="lineNoCov">          0 :   const char* const type_param = test_info.type_param();</span>
<span class="lineNum">    2674 </span><span class="lineNoCov">          0 :   const char* const value_param = test_info.value_param();</span>
<span class="lineNum">    2675 </span>            : 
<span class="lineNum">    2676 </span><span class="lineNoCov">          0 :   if (type_param != NULL || value_param != NULL) {</span>
<span class="lineNum">    2677 </span><span class="lineNoCov">          0 :     printf(&quot;, where &quot;);</span>
<span class="lineNum">    2678 </span><span class="lineNoCov">          0 :     if (type_param != NULL) {</span>
<span class="lineNum">    2679 </span><span class="lineNoCov">          0 :       printf(&quot;%s = %s&quot;, kTypeParamLabel, type_param);</span>
<span class="lineNum">    2680 </span><span class="lineNoCov">          0 :       if (value_param != NULL)</span>
<span class="lineNum">    2681 </span><span class="lineNoCov">          0 :         printf(&quot; and &quot;);</span>
<span class="lineNum">    2682 </span>            :     }
<span class="lineNum">    2683 </span><span class="lineNoCov">          0 :     if (value_param != NULL) {</span>
<span class="lineNum">    2684 </span><span class="lineNoCov">          0 :       printf(&quot;%s = %s&quot;, kValueParamLabel, value_param);</span>
<span class="lineNum">    2685 </span>            :     }
<span class="lineNum">    2686 </span>            :   }
<span class="lineNum">    2687 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2688 </span>            : 
<span class="lineNum">    2689 </span>            : // This class implements the TestEventListener interface.
<a name="2690"><span class="lineNum">    2690 </span>            : //</a>
<span class="lineNum">    2691 </span>            : // Class PrettyUnitTestResultPrinter is copyable.
<a name="2692"><span class="lineNum">    2692 </span><span class="lineNoCov">          0 : class PrettyUnitTestResultPrinter : public TestEventListener {</span></a>
<a name="2693"><span class="lineNum">    2693 </span>            :  public:</a>
<span class="lineNum">    2694 </span><span class="lineNoCov">          0 :   PrettyUnitTestResultPrinter() {}</span>
<span class="lineNum">    2695 </span><span class="lineNoCov">          0 :   static void PrintTestName(const char * test_case, const char * test) {</span>
<span class="lineNum">    2696 </span><span class="lineNoCov">          0 :     printf(&quot;%s.%s&quot;, test_case, test);</span>
<span class="lineNum">    2697 </span><span class="lineNoCov">          0 :   }</span>
<a name="2698"><span class="lineNum">    2698 </span>            : </a>
<span class="lineNum">    2699 </span>            :   // The following methods override what's in the TestEventListener class.
<span class="lineNum">    2700 </span><span class="lineNoCov">          0 :   virtual void OnTestProgramStart(const UnitTest&amp; /*unit_test*/) {}</span>
<a name="2701"><span class="lineNum">    2701 </span>            :   virtual void OnTestIterationStart(const UnitTest&amp; unit_test, int iteration);</a>
<span class="lineNum">    2702 </span>            :   virtual void OnEnvironmentsSetUpStart(const UnitTest&amp; unit_test);
<span class="lineNum">    2703 </span><span class="lineNoCov">          0 :   virtual void OnEnvironmentsSetUpEnd(const UnitTest&amp; /*unit_test*/) {}</span>
<span class="lineNum">    2704 </span>            :   virtual void OnTestCaseStart(const TestCase&amp; test_case);
<span class="lineNum">    2705 </span>            :   virtual void OnTestStart(const TestInfo&amp; test_info);
<span class="lineNum">    2706 </span>            :   virtual void OnTestPartResult(const TestPartResult&amp; result);
<span class="lineNum">    2707 </span>            :   virtual void OnTestEnd(const TestInfo&amp; test_info);
<a name="2708"><span class="lineNum">    2708 </span>            :   virtual void OnTestCaseEnd(const TestCase&amp; test_case);</a>
<span class="lineNum">    2709 </span>            :   virtual void OnEnvironmentsTearDownStart(const UnitTest&amp; unit_test);
<a name="2710"><span class="lineNum">    2710 </span><span class="lineNoCov">          0 :   virtual void OnEnvironmentsTearDownEnd(const UnitTest&amp; /*unit_test*/) {}</span></a>
<span class="lineNum">    2711 </span>            :   virtual void OnTestIterationEnd(const UnitTest&amp; unit_test, int iteration);
<span class="lineNum">    2712 </span><span class="lineNoCov">          0 :   virtual void OnTestProgramEnd(const UnitTest&amp; /*unit_test*/) {}</span>
<span class="lineNum">    2713 </span>            : 
<span class="lineNum">    2714 </span>            :  private:
<span class="lineNum">    2715 </span>            :   static void PrintFailedTests(const UnitTest&amp; unit_test);
<span class="lineNum">    2716 </span>            : };
<a name="2717"><span class="lineNum">    2717 </span>            : </a>
<span class="lineNum">    2718 </span>            :   // Fired before each iteration of tests starts.
<span class="lineNum">    2719 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestIterationStart(</span>
<span class="lineNum">    2720 </span>            :     const UnitTest&amp; unit_test, int iteration) {
<span class="lineNum">    2721 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(repeat) != 1)</span>
<span class="lineNum">    2722 </span><span class="lineNoCov">          0 :     printf(&quot;\nRepeating all tests (iteration %d) . . .\n\n&quot;, iteration + 1);</span>
<span class="lineNum">    2723 </span>            : 
<span class="lineNum">    2724 </span><span class="lineNoCov">          0 :   const char* const filter = GTEST_FLAG(filter).c_str();</span>
<span class="lineNum">    2725 </span>            : 
<span class="lineNum">    2726 </span>            :   // Prints the filter if it's not *.  This reminds the user that some
<span class="lineNum">    2727 </span>            :   // tests may be skipped.
<span class="lineNum">    2728 </span><span class="lineNoCov">          0 :   if (!String::CStringEquals(filter, kUniversalFilter)) {</span>
<span class="lineNum">    2729 </span>            :     ColoredPrintf(COLOR_YELLOW,
<span class="lineNum">    2730 </span><span class="lineNoCov">          0 :                   &quot;Note: %s filter = %s\n&quot;, GTEST_NAME_, filter);</span>
<span class="lineNum">    2731 </span>            :   }
<span class="lineNum">    2732 </span>            : 
<span class="lineNum">    2733 </span><span class="lineNoCov">          0 :   if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {</span>
<span class="lineNum">    2734 </span><span class="lineNoCov">          0 :     const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);</span>
<span class="lineNum">    2735 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_YELLOW,</span>
<span class="lineNum">    2736 </span>            :                   &quot;Note: This is test shard %d of %s.\n&quot;,
<span class="lineNum">    2737 </span>            :                   static_cast&lt;int&gt;(shard_index) + 1,
<span class="lineNum">    2738 </span><span class="lineNoCov">          0 :                   internal::posix::GetEnv(kTestTotalShards));</span>
<span class="lineNum">    2739 </span>            :   }
<span class="lineNum">    2740 </span>            : 
<span class="lineNum">    2741 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(shuffle)) {</span>
<span class="lineNum">    2742 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_YELLOW,</span>
<span class="lineNum">    2743 </span>            :                   &quot;Note: Randomizing tests' orders with a seed of %d .\n&quot;,
<span class="lineNum">    2744 </span><span class="lineNoCov">          0 :                   unit_test.random_seed());</span>
<span class="lineNum">    2745 </span>            :   }
<span class="lineNum">    2746 </span>            : 
<span class="lineNum">    2747 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[==========] &quot;);</span>
<span class="lineNum">    2748 </span><span class="lineNoCov">          0 :   printf(&quot;Running %s from %s.\n&quot;,</span>
<span class="lineNum">    2749 </span><span class="lineNoCov">          0 :          FormatTestCount(unit_test.test_to_run_count()).c_str(),</span>
<span class="lineNum">    2750 </span><span class="lineNoCov">          0 :          FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());</span>
<span class="lineNum">    2751 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2752"><span class="lineNum">    2752 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2753 </span>            : 
<span class="lineNum">    2754 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(</span>
<span class="lineNum">    2755 </span>            :     const UnitTest&amp; /*unit_test*/) {
<span class="lineNum">    2756 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[----------] &quot;);</span>
<span class="lineNum">    2757 </span><span class="lineNoCov">          0 :   printf(&quot;Global test environment set-up.\n&quot;);</span>
<span class="lineNum">    2758 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2759"><span class="lineNum">    2759 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2760 </span>            : 
<span class="lineNum">    2761 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase&amp; test_case) {</span>
<span class="lineNum">    2762 </span>            :   const std::string counts =
<span class="lineNum">    2763 </span><span class="lineNoCov">          0 :       FormatCountableNoun(test_case.test_to_run_count(), &quot;test&quot;, &quot;tests&quot;);</span>
<span class="lineNum">    2764 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN, &quot;[----------] &quot;);</span>
<span class="lineNum">    2765 </span><span class="lineNoCov">          0 :   printf(&quot;%s from %s&quot;, counts.c_str(), test_case.name());</span>
<span class="lineNum">    2766 </span><span class="lineNoCov">          0 :   if (test_case.type_param() == NULL) {</span>
<span class="lineNum">    2767 </span><span class="lineNoCov">          0 :     printf(&quot;\n&quot;);</span>
<span class="lineNum">    2768 </span>            :   } else {
<span class="lineNum">    2769 </span><span class="lineNoCov">          0 :     printf(&quot;, where %s = %s\n&quot;, kTypeParamLabel, test_case.type_param());</span>
<span class="lineNum">    2770 </span>            :   }
<span class="lineNum">    2771 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2772"><span class="lineNum">    2772 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2773 </span>            : 
<span class="lineNum">    2774 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo&amp; test_info) {</span>
<span class="lineNum">    2775 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[ RUN      ] &quot;);</span>
<span class="lineNum">    2776 </span><span class="lineNoCov">          0 :   PrintTestName(test_info.test_case_name(), test_info.name());</span>
<span class="lineNum">    2777 </span><span class="lineNoCov">          0 :   printf(&quot;\n&quot;);</span>
<span class="lineNum">    2778 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<span class="lineNum">    2779 </span><span class="lineNoCov">          0 : }</span>
<a name="2780"><span class="lineNum">    2780 </span>            : </a>
<span class="lineNum">    2781 </span>            : // Called after an assertion failure.
<span class="lineNum">    2782 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestPartResult(</span>
<span class="lineNum">    2783 </span>            :     const TestPartResult&amp; result) {
<span class="lineNum">    2784 </span>            :   // If the test part succeeded, we don't need to do anything.
<span class="lineNum">    2785 </span><span class="lineNoCov">          0 :   if (result.type() == TestPartResult::kSuccess)</span>
<span class="lineNum">    2786 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">    2787 </span>            : 
<span class="lineNum">    2788 </span>            :   // Print failure message from the assertion (e.g. expected this and got that).
<span class="lineNum">    2789 </span><span class="lineNoCov">          0 :   PrintTestPartResult(result);</span>
<span class="lineNum">    2790 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2791"><span class="lineNum">    2791 </span>            : }</a>
<span class="lineNum">    2792 </span>            : 
<span class="lineNum">    2793 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo&amp; test_info) {</span>
<span class="lineNum">    2794 </span><span class="lineNoCov">          0 :   if (test_info.result()-&gt;Passed()) {</span>
<span class="lineNum">    2795 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_GREEN, &quot;[       OK ] &quot;);</span>
<span class="lineNum">    2796 </span>            :   } else {
<span class="lineNum">    2797 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_RED, &quot;[  FAILED  ] &quot;);</span>
<span class="lineNum">    2798 </span>            :   }
<span class="lineNum">    2799 </span><span class="lineNoCov">          0 :   PrintTestName(test_info.test_case_name(), test_info.name());</span>
<span class="lineNum">    2800 </span><span class="lineNoCov">          0 :   if (test_info.result()-&gt;Failed())</span>
<span class="lineNum">    2801 </span><span class="lineNoCov">          0 :     PrintFullTestCommentIfPresent(test_info);</span>
<span class="lineNum">    2802 </span>            : 
<span class="lineNum">    2803 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(print_time)) {</span>
<span class="lineNum">    2804 </span><span class="lineNoCov">          0 :     printf(&quot; (%s ms)\n&quot;, internal::StreamableToString(</span>
<span class="lineNum">    2805 </span><span class="lineNoCov">          0 :            test_info.result()-&gt;elapsed_time()).c_str());</span>
<span class="lineNum">    2806 </span>            :   } else {
<span class="lineNum">    2807 </span><span class="lineNoCov">          0 :     printf(&quot;\n&quot;);</span>
<span class="lineNum">    2808 </span>            :   }
<span class="lineNum">    2809 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2810"><span class="lineNum">    2810 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2811 </span>            : 
<span class="lineNum">    2812 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase&amp; test_case) {</span>
<span class="lineNum">    2813 </span><span class="lineNoCov">          0 :   if (!GTEST_FLAG(print_time)) return;</span>
<span class="lineNum">    2814 </span>            : 
<span class="lineNum">    2815 </span>            :   const std::string counts =
<span class="lineNum">    2816 </span><span class="lineNoCov">          0 :       FormatCountableNoun(test_case.test_to_run_count(), &quot;test&quot;, &quot;tests&quot;);</span>
<span class="lineNum">    2817 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN, &quot;[----------] &quot;);</span>
<span class="lineNum">    2818 </span><span class="lineNoCov">          0 :   printf(&quot;%s from %s (%s ms total)\n\n&quot;,</span>
<span class="lineNum">    2819 </span>            :          counts.c_str(), test_case.name(),
<span class="lineNum">    2820 </span><span class="lineNoCov">          0 :          internal::StreamableToString(test_case.elapsed_time()).c_str());</span>
<span class="lineNum">    2821 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<a name="2822"><span class="lineNum">    2822 </span>            : }</a>
<span class="lineNum">    2823 </span>            : 
<span class="lineNum">    2824 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(</span>
<span class="lineNum">    2825 </span>            :     const UnitTest&amp; /*unit_test*/) {
<span class="lineNum">    2826 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[----------] &quot;);</span>
<span class="lineNum">    2827 </span><span class="lineNoCov">          0 :   printf(&quot;Global test environment tear-down\n&quot;);</span>
<span class="lineNum">    2828 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<span class="lineNum">    2829 </span><span class="lineNoCov">          0 : }</span>
<a name="2830"><span class="lineNum">    2830 </span>            : </a>
<span class="lineNum">    2831 </span>            : // Internal helper for printing the list of failed tests.
<span class="lineNum">    2832 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest&amp; unit_test) {</span>
<span class="lineNum">    2833 </span><span class="lineNoCov">          0 :   const int failed_test_count = unit_test.failed_test_count();</span>
<span class="lineNum">    2834 </span><span class="lineNoCov">          0 :   if (failed_test_count == 0) {</span>
<span class="lineNum">    2835 </span><span class="lineNoCov">          0 :     return;</span>
<span class="lineNum">    2836 </span>            :   }
<span class="lineNum">    2837 </span>            : 
<span class="lineNum">    2838 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; unit_test.total_test_case_count(); ++i) {</span>
<span class="lineNum">    2839 </span><span class="lineNoCov">          0 :     const TestCase&amp; test_case = *unit_test.GetTestCase(i);</span>
<span class="lineNum">    2840 </span><span class="lineNoCov">          0 :     if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {</span>
<span class="lineNum">    2841 </span><span class="lineNoCov">          0 :       continue;</span>
<span class="lineNum">    2842 </span>            :     }
<span class="lineNum">    2843 </span><span class="lineNoCov">          0 :     for (int j = 0; j &lt; test_case.total_test_count(); ++j) {</span>
<span class="lineNum">    2844 </span><span class="lineNoCov">          0 :       const TestInfo&amp; test_info = *test_case.GetTestInfo(j);</span>
<span class="lineNum">    2845 </span><span class="lineNoCov">          0 :       if (!test_info.should_run() || test_info.result()-&gt;Passed()) {</span>
<span class="lineNum">    2846 </span><span class="lineNoCov">          0 :         continue;</span>
<span class="lineNum">    2847 </span>            :       }
<span class="lineNum">    2848 </span><span class="lineNoCov">          0 :       ColoredPrintf(COLOR_RED, &quot;[  FAILED  ] &quot;);</span>
<span class="lineNum">    2849 </span><span class="lineNoCov">          0 :       printf(&quot;%s.%s&quot;, test_case.name(), test_info.name());</span>
<span class="lineNum">    2850 </span><span class="lineNoCov">          0 :       PrintFullTestCommentIfPresent(test_info);</span>
<span class="lineNum">    2851 </span><span class="lineNoCov">          0 :       printf(&quot;\n&quot;);</span>
<span class="lineNum">    2852 </span>            :     }
<span class="lineNum">    2853 </span>            :   }
<a name="2854"><span class="lineNum">    2854 </span>            : }</a>
<span class="lineNum">    2855 </span>            : 
<span class="lineNum">    2856 </span><span class="lineNoCov">          0 : void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest&amp; unit_test,</span>
<span class="lineNum">    2857 </span>            :                                                      int /*iteration*/) {
<span class="lineNum">    2858 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[==========] &quot;);</span>
<span class="lineNum">    2859 </span><span class="lineNoCov">          0 :   printf(&quot;%s from %s ran.&quot;,</span>
<span class="lineNum">    2860 </span><span class="lineNoCov">          0 :          FormatTestCount(unit_test.test_to_run_count()).c_str(),</span>
<span class="lineNum">    2861 </span><span class="lineNoCov">          0 :          FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());</span>
<span class="lineNum">    2862 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(print_time)) {</span>
<span class="lineNum">    2863 </span><span class="lineNoCov">          0 :     printf(&quot; (%s ms total)&quot;,</span>
<span class="lineNum">    2864 </span><span class="lineNoCov">          0 :            internal::StreamableToString(unit_test.elapsed_time()).c_str());</span>
<span class="lineNum">    2865 </span>            :   }
<span class="lineNum">    2866 </span><span class="lineNoCov">          0 :   printf(&quot;\n&quot;);</span>
<span class="lineNum">    2867 </span><span class="lineNoCov">          0 :   ColoredPrintf(COLOR_GREEN,  &quot;[  PASSED  ] &quot;);</span>
<span class="lineNum">    2868 </span><span class="lineNoCov">          0 :   printf(&quot;%s.\n&quot;, FormatTestCount(unit_test.successful_test_count()).c_str());</span>
<span class="lineNum">    2869 </span>            : 
<span class="lineNum">    2870 </span><span class="lineNoCov">          0 :   int num_failures = unit_test.failed_test_count();</span>
<span class="lineNum">    2871 </span><span class="lineNoCov">          0 :   if (!unit_test.Passed()) {</span>
<span class="lineNum">    2872 </span><span class="lineNoCov">          0 :     const int failed_test_count = unit_test.failed_test_count();</span>
<span class="lineNum">    2873 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_RED,  &quot;[  FAILED  ] &quot;);</span>
<span class="lineNum">    2874 </span><span class="lineNoCov">          0 :     printf(&quot;%s, listed below:\n&quot;, FormatTestCount(failed_test_count).c_str());</span>
<span class="lineNum">    2875 </span><span class="lineNoCov">          0 :     PrintFailedTests(unit_test);</span>
<span class="lineNum">    2876 </span><span class="lineNoCov">          0 :     printf(&quot;\n%2d FAILED %s\n&quot;, num_failures,</span>
<span class="lineNum">    2877 </span><span class="lineNoCov">          0 :                         num_failures == 1 ? &quot;TEST&quot; : &quot;TESTS&quot;);</span>
<span class="lineNum">    2878 </span>            :   }
<span class="lineNum">    2879 </span>            : 
<span class="lineNum">    2880 </span><span class="lineNoCov">          0 :   int num_disabled = unit_test.reportable_disabled_test_count();</span>
<span class="lineNum">    2881 </span><span class="lineNoCov">          0 :   if (num_disabled &amp;&amp; !GTEST_FLAG(also_run_disabled_tests)) {</span>
<span class="lineNum">    2882 </span><span class="lineNoCov">          0 :     if (!num_failures) {</span>
<span class="lineNum">    2883 </span><span class="lineNoCov">          0 :       printf(&quot;\n&quot;);  // Add a spacer if no FAILURE banner is displayed.</span>
<span class="lineNum">    2884 </span>            :     }
<span class="lineNum">    2885 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_YELLOW,</span>
<span class="lineNum">    2886 </span>            :                   &quot;  YOU HAVE %d DISABLED %s\n\n&quot;,
<span class="lineNum">    2887 </span>            :                   num_disabled,
<span class="lineNum">    2888 </span><span class="lineNoCov">          0 :                   num_disabled == 1 ? &quot;TEST&quot; : &quot;TESTS&quot;);</span>
<span class="lineNum">    2889 </span>            :   }
<span class="lineNum">    2890 </span>            :   // Ensure that Google Test output is printed before, e.g., heapchecker output.
<span class="lineNum">    2891 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<span class="lineNum">    2892 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    2893 </span>            : 
<span class="lineNum">    2894 </span>            : // End PrettyUnitTestResultPrinter
<span class="lineNum">    2895 </span>            : 
<span class="lineNum">    2896 </span>            : // class TestEventRepeater
<span class="lineNum">    2897 </span>            : //
<span class="lineNum">    2898 </span>            : // This class forwards events to other event listeners.
<a name="2899"><span class="lineNum">    2899 </span>            : class TestEventRepeater : public TestEventListener {</a>
<span class="lineNum">    2900 </span>            :  public:
<span class="lineNum">    2901 </span><span class="lineNoCov">          0 :   TestEventRepeater() : forwarding_enabled_(true) {}</span>
<span class="lineNum">    2902 </span>            :   virtual ~TestEventRepeater();
<span class="lineNum">    2903 </span>            :   void Append(TestEventListener *listener);
<span class="lineNum">    2904 </span>            :   TestEventListener* Release(TestEventListener* listener);
<span class="lineNum">    2905 </span>            : 
<a name="2906"><span class="lineNum">    2906 </span>            :   // Controls whether events will be forwarded to listeners_. Set to false</a>
<a name="2907"><span class="lineNum">    2907 </span>            :   // in death test child processes.</a>
<span class="lineNum">    2908 </span><span class="lineNoCov">          0 :   bool forwarding_enabled() const { return forwarding_enabled_; }</span>
<span class="lineNum">    2909 </span><span class="lineNoCov">          0 :   void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }</span>
<span class="lineNum">    2910 </span>            : 
<span class="lineNum">    2911 </span>            :   virtual void OnTestProgramStart(const UnitTest&amp; unit_test);
<span class="lineNum">    2912 </span>            :   virtual void OnTestIterationStart(const UnitTest&amp; unit_test, int iteration);
<span class="lineNum">    2913 </span>            :   virtual void OnEnvironmentsSetUpStart(const UnitTest&amp; unit_test);
<span class="lineNum">    2914 </span>            :   virtual void OnEnvironmentsSetUpEnd(const UnitTest&amp; unit_test);
<span class="lineNum">    2915 </span>            :   virtual void OnTestCaseStart(const TestCase&amp; test_case);
<span class="lineNum">    2916 </span>            :   virtual void OnTestStart(const TestInfo&amp; test_info);
<span class="lineNum">    2917 </span>            :   virtual void OnTestPartResult(const TestPartResult&amp; result);
<span class="lineNum">    2918 </span>            :   virtual void OnTestEnd(const TestInfo&amp; test_info);
<span class="lineNum">    2919 </span>            :   virtual void OnTestCaseEnd(const TestCase&amp; test_case);
<span class="lineNum">    2920 </span>            :   virtual void OnEnvironmentsTearDownStart(const UnitTest&amp; unit_test);
<span class="lineNum">    2921 </span>            :   virtual void OnEnvironmentsTearDownEnd(const UnitTest&amp; unit_test);
<span class="lineNum">    2922 </span>            :   virtual void OnTestIterationEnd(const UnitTest&amp; unit_test, int iteration);
<span class="lineNum">    2923 </span>            :   virtual void OnTestProgramEnd(const UnitTest&amp; unit_test);
<span class="lineNum">    2924 </span>            : 
<span class="lineNum">    2925 </span>            :  private:
<span class="lineNum">    2926 </span>            :   // Controls whether events will be forwarded to listeners_. Set to false
<span class="lineNum">    2927 </span>            :   // in death test child processes.
<span class="lineNum">    2928 </span>            :   bool forwarding_enabled_;
<span class="lineNum">    2929 </span>            :   // The list of listeners that receive events.
<span class="lineNum">    2930 </span>            :   std::vector&lt;TestEventListener*&gt; listeners_;
<span class="lineNum">    2931 </span>            : 
<span class="lineNum">    2932 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);
<a name="2933"><span class="lineNum">    2933 </span>            : };</a>
<span class="lineNum">    2934 </span>            : 
<span class="lineNum">    2935 </span><span class="lineNoCov">          0 : TestEventRepeater::~TestEventRepeater() {</span>
<span class="lineNum">    2936 </span><span class="lineNoCov">          0 :   ForEach(listeners_, Delete&lt;TestEventListener&gt;);</span>
<a name="2937"><span class="lineNum">    2937 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2938 </span>            : 
<span class="lineNum">    2939 </span><span class="lineNoCov">          0 : void TestEventRepeater::Append(TestEventListener *listener) {</span>
<span class="lineNum">    2940 </span><span class="lineNoCov">          0 :   listeners_.push_back(listener);</span>
<span class="lineNum">    2941 </span><span class="lineNoCov">          0 : }</span>
<a name="2942"><span class="lineNum">    2942 </span>            : </a>
<span class="lineNum">    2943 </span>            : // TODO(vladl@google.com): Factor the search functionality into Vector::Find.
<span class="lineNum">    2944 </span><span class="lineNoCov">          0 : TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {</span>
<span class="lineNum">    2945 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; listeners_.size(); ++i) {</span>
<span class="lineNum">    2946 </span><span class="lineNoCov">          0 :     if (listeners_[i] == listener) {</span>
<span class="lineNum">    2947 </span><span class="lineNoCov">          0 :       listeners_.erase(listeners_.begin() + i);</span>
<span class="lineNum">    2948 </span><span class="lineNoCov">          0 :       return listener;</span>
<span class="lineNum">    2949 </span>            :     }
<span class="lineNum">    2950 </span>            :   }
<span class="lineNum">    2951 </span>            : 
<span class="lineNum">    2952 </span><span class="lineNoCov">          0 :   return NULL;</span>
<span class="lineNum">    2953 </span>            : }
<span class="lineNum">    2954 </span>            : 
<span class="lineNum">    2955 </span>            : // Since most methods are very similar, use macros to reduce boilerplate.
<span class="lineNum">    2956 </span>            : // This defines a member that forwards the call to all listeners.
<span class="lineNum">    2957 </span>            : #define GTEST_REPEATER_METHOD_(Name, Type) \
<span class="lineNum">    2958 </span>            : void TestEventRepeater::Name(const Type&amp; parameter) { \
<span class="lineNum">    2959 </span>            :   if (forwarding_enabled_) { \
<span class="lineNum">    2960 </span>            :     for (size_t i = 0; i &lt; listeners_.size(); i++) { \
<span class="lineNum">    2961 </span>            :       listeners_[i]-&gt;Name(parameter); \
<span class="lineNum">    2962 </span>            :     } \
<span class="lineNum">    2963 </span>            :   } \
<span class="lineNum">    2964 </span>            : }
<span class="lineNum">    2965 </span>            : // This defines a member that forwards the call to all listeners in reverse
<span class="lineNum">    2966 </span>            : // order.
<span class="lineNum">    2967 </span>            : #define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
<span class="lineNum">    2968 </span>            : void TestEventRepeater::Name(const Type&amp; parameter) { \
<span class="lineNum">    2969 </span>            :   if (forwarding_enabled_) { \
<span class="lineNum">    2970 </span>            :     for (int i = static_cast&lt;int&gt;(listeners_.size()) - 1; i &gt;= 0; i--) { \
<span class="lineNum">    2971 </span>            :       listeners_[i]-&gt;Name(parameter); \
<span class="lineNum">    2972 </span>            :     } \
<span class="lineNum">    2973 </span>            :   } \
<a name="2974"><span class="lineNum">    2974 </span>            : }</a>
<a name="2975"><span class="lineNum">    2975 </span>            : </a>
<a name="2976"><span class="lineNum">    2976 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)</span></a>
<a name="2977"><span class="lineNum">    2977 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)</span></a>
<a name="2978"><span class="lineNum">    2978 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)</span></a>
<a name="2979"><span class="lineNum">    2979 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)</span></a>
<a name="2980"><span class="lineNum">    2980 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)</span></a>
<a name="2981"><span class="lineNum">    2981 </span><span class="lineNoCov">          0 : GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)</span></a>
<a name="2982"><span class="lineNum">    2982 </span><span class="lineNoCov">          0 : GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)</span></a>
<a name="2983"><span class="lineNum">    2983 </span><span class="lineNoCov">          0 : GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)</span></a>
<a name="2984"><span class="lineNum">    2984 </span><span class="lineNoCov">          0 : GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)</span></a>
<span class="lineNum">    2985 </span><span class="lineNoCov">          0 : GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)</span>
<span class="lineNum">    2986 </span><span class="lineNoCov">          0 : GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)</span>
<span class="lineNum">    2987 </span>            : 
<span class="lineNum">    2988 </span>            : #undef GTEST_REPEATER_METHOD_
<a name="2989"><span class="lineNum">    2989 </span>            : #undef GTEST_REVERSE_REPEATER_METHOD_</a>
<span class="lineNum">    2990 </span>            : 
<span class="lineNum">    2991 </span><span class="lineNoCov">          0 : void TestEventRepeater::OnTestIterationStart(const UnitTest&amp; unit_test,</span>
<span class="lineNum">    2992 </span>            :                                              int iteration) {
<span class="lineNum">    2993 </span><span class="lineNoCov">          0 :   if (forwarding_enabled_) {</span>
<span class="lineNum">    2994 </span><span class="lineNoCov">          0 :     for (size_t i = 0; i &lt; listeners_.size(); i++) {</span>
<span class="lineNum">    2995 </span><span class="lineNoCov">          0 :       listeners_[i]-&gt;OnTestIterationStart(unit_test, iteration);</span>
<span class="lineNum">    2996 </span>            :     }
<span class="lineNum">    2997 </span>            :   }
<a name="2998"><span class="lineNum">    2998 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    2999 </span>            : 
<span class="lineNum">    3000 </span><span class="lineNoCov">          0 : void TestEventRepeater::OnTestIterationEnd(const UnitTest&amp; unit_test,</span>
<span class="lineNum">    3001 </span>            :                                            int iteration) {
<span class="lineNum">    3002 </span><span class="lineNoCov">          0 :   if (forwarding_enabled_) {</span>
<span class="lineNum">    3003 </span><span class="lineNoCov">          0 :     for (int i = static_cast&lt;int&gt;(listeners_.size()) - 1; i &gt;= 0; i--) {</span>
<span class="lineNum">    3004 </span><span class="lineNoCov">          0 :       listeners_[i]-&gt;OnTestIterationEnd(unit_test, iteration);</span>
<span class="lineNum">    3005 </span>            :     }
<span class="lineNum">    3006 </span>            :   }
<span class="lineNum">    3007 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3008 </span>            : 
<span class="lineNum">    3009 </span>            : // End TestEventRepeater
<a name="3010"><span class="lineNum">    3010 </span>            : </a>
<span class="lineNum">    3011 </span>            : // This class generates an XML output file.
<span class="lineNum">    3012 </span><span class="lineNoCov">          0 : class XmlUnitTestResultPrinter : public EmptyTestEventListener {</span>
<span class="lineNum">    3013 </span>            :  public:
<span class="lineNum">    3014 </span>            :   explicit XmlUnitTestResultPrinter(const char* output_file);
<span class="lineNum">    3015 </span>            : 
<span class="lineNum">    3016 </span>            :   virtual void OnTestIterationEnd(const UnitTest&amp; unit_test, int iteration);
<span class="lineNum">    3017 </span>            : 
<span class="lineNum">    3018 </span>            :  private:
<a name="3019"><span class="lineNum">    3019 </span>            :   // Is c a whitespace character that is normalized to a space character</a>
<span class="lineNum">    3020 </span>            :   // when it appears in an XML attribute value?
<span class="lineNum">    3021 </span><span class="lineNoCov">          0 :   static bool IsNormalizableWhitespace(char c) {</span>
<span class="lineNum">    3022 </span><span class="lineNoCov">          0 :     return c == 0x9 || c == 0xA || c == 0xD;</span>
<span class="lineNum">    3023 </span>            :   }
<a name="3024"><span class="lineNum">    3024 </span>            : </a>
<span class="lineNum">    3025 </span>            :   // May c appear in a well-formed XML document?
<span class="lineNum">    3026 </span><span class="lineNoCov">          0 :   static bool IsValidXmlCharacter(char c) {</span>
<span class="lineNum">    3027 </span><span class="lineNoCov">          0 :     return IsNormalizableWhitespace(c) || c &gt;= 0x20;</span>
<span class="lineNum">    3028 </span>            :   }
<span class="lineNum">    3029 </span>            : 
<span class="lineNum">    3030 </span>            :   // Returns an XML-escaped copy of the input string str.  If
<span class="lineNum">    3031 </span>            :   // is_attribute is true, the text is meant to appear as an attribute
<span class="lineNum">    3032 </span>            :   // value, and normalizable whitespace is preserved by replacing it
<span class="lineNum">    3033 </span>            :   // with character references.
<span class="lineNum">    3034 </span>            :   static std::string EscapeXml(const std::string&amp; str, bool is_attribute);
<span class="lineNum">    3035 </span>            : 
<span class="lineNum">    3036 </span>            :   // Returns the given string with all characters invalid in XML removed.
<span class="lineNum">    3037 </span>            :   static std::string RemoveInvalidXmlCharacters(const std::string&amp; str);
<a name="3038"><span class="lineNum">    3038 </span>            : </a>
<span class="lineNum">    3039 </span>            :   // Convenience wrapper around EscapeXml when str is an attribute value.
<span class="lineNum">    3040 </span><span class="lineNoCov">          0 :   static std::string EscapeXmlAttribute(const std::string&amp; str) {</span>
<span class="lineNum">    3041 </span><span class="lineNoCov">          0 :     return EscapeXml(str, true);</span>
<span class="lineNum">    3042 </span>            :   }
<span class="lineNum">    3043 </span>            : 
<span class="lineNum">    3044 </span>            :   // Convenience wrapper around EscapeXml when str is not an attribute value.
<span class="lineNum">    3045 </span>            :   static std::string EscapeXmlText(const char* str) {
<span class="lineNum">    3046 </span>            :     return EscapeXml(str, false);
<span class="lineNum">    3047 </span>            :   }
<span class="lineNum">    3048 </span>            : 
<span class="lineNum">    3049 </span>            :   // Verifies that the given attribute belongs to the given element and
<span class="lineNum">    3050 </span>            :   // streams the attribute as XML.
<span class="lineNum">    3051 </span>            :   static void OutputXmlAttribute(std::ostream* stream,
<span class="lineNum">    3052 </span>            :                                  const std::string&amp; element_name,
<span class="lineNum">    3053 </span>            :                                  const std::string&amp; name,
<span class="lineNum">    3054 </span>            :                                  const std::string&amp; value);
<span class="lineNum">    3055 </span>            : 
<span class="lineNum">    3056 </span>            :   // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
<span class="lineNum">    3057 </span>            :   static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
<span class="lineNum">    3058 </span>            : 
<span class="lineNum">    3059 </span>            :   // Streams an XML representation of a TestInfo object.
<span class="lineNum">    3060 </span>            :   static void OutputXmlTestInfo(::std::ostream* stream,
<span class="lineNum">    3061 </span>            :                                 const char* test_case_name,
<span class="lineNum">    3062 </span>            :                                 const TestInfo&amp; test_info);
<span class="lineNum">    3063 </span>            : 
<span class="lineNum">    3064 </span>            :   // Prints an XML representation of a TestCase object
<span class="lineNum">    3065 </span>            :   static void PrintXmlTestCase(::std::ostream* stream,
<span class="lineNum">    3066 </span>            :                                const TestCase&amp; test_case);
<span class="lineNum">    3067 </span>            : 
<span class="lineNum">    3068 </span>            :   // Prints an XML summary of unit_test to output stream out.
<span class="lineNum">    3069 </span>            :   static void PrintXmlUnitTest(::std::ostream* stream,
<span class="lineNum">    3070 </span>            :                                const UnitTest&amp; unit_test);
<span class="lineNum">    3071 </span>            : 
<span class="lineNum">    3072 </span>            :   // Produces a string representing the test properties in a result as space
<span class="lineNum">    3073 </span>            :   // delimited XML attributes based on the property key=&quot;value&quot; pairs.
<span class="lineNum">    3074 </span>            :   // When the std::string is not empty, it includes a space at the beginning,
<span class="lineNum">    3075 </span>            :   // to delimit this attribute from prior attributes.
<span class="lineNum">    3076 </span>            :   static std::string TestPropertiesAsXmlAttributes(const TestResult&amp; result);
<span class="lineNum">    3077 </span>            : 
<span class="lineNum">    3078 </span>            :   // The output file.
<span class="lineNum">    3079 </span>            :   const std::string output_file_;
<span class="lineNum">    3080 </span>            : 
<span class="lineNum">    3081 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);
<span class="lineNum">    3082 </span>            : };
<a name="3083"><span class="lineNum">    3083 </span>            : </a>
<span class="lineNum">    3084 </span>            : // Creates a new XmlUnitTestResultPrinter.
<span class="lineNum">    3085 </span><span class="lineNoCov">          0 : XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)</span>
<span class="lineNum">    3086 </span><span class="lineNoCov">          0 :     : output_file_(output_file) {</span>
<span class="lineNum">    3087 </span><span class="lineNoCov">          0 :   if (output_file_.c_str() == NULL || output_file_.empty()) {</span>
<span class="lineNum">    3088 </span><span class="lineNoCov">          0 :     fprintf(stderr, &quot;XML output file may not be null\n&quot;);</span>
<span class="lineNum">    3089 </span><span class="lineNoCov">          0 :     fflush(stderr);</span>
<span class="lineNum">    3090 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    3091 </span>            :   }
<span class="lineNum">    3092 </span><span class="lineNoCov">          0 : }</span>
<a name="3093"><span class="lineNum">    3093 </span>            : </a>
<span class="lineNum">    3094 </span>            : // Called after the unit test ends.
<span class="lineNum">    3095 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest&amp; unit_test,</span>
<span class="lineNum">    3096 </span>            :                                                   int /*iteration*/) {
<span class="lineNum">    3097 </span><span class="lineNoCov">          0 :   FILE* xmlout = NULL;</span>
<span class="lineNum">    3098 </span><span class="lineNoCov">          0 :   FilePath output_file(output_file_);</span>
<span class="lineNum">    3099 </span><span class="lineNoCov">          0 :   FilePath output_dir(output_file.RemoveFileName());</span>
<span class="lineNum">    3100 </span>            : 
<span class="lineNum">    3101 </span><span class="lineNoCov">          0 :   if (output_dir.CreateDirectoriesRecursively()) {</span>
<span class="lineNum">    3102 </span><span class="lineNoCov">          0 :     xmlout = posix::FOpen(output_file_.c_str(), &quot;w&quot;);</span>
<span class="lineNum">    3103 </span>            :   }
<span class="lineNum">    3104 </span><span class="lineNoCov">          0 :   if (xmlout == NULL) {</span>
<span class="lineNum">    3105 </span>            :     // TODO(wan): report the reason of the failure.
<span class="lineNum">    3106 </span>            :     //
<span class="lineNum">    3107 </span>            :     // We don't do it for now as:
<span class="lineNum">    3108 </span>            :     //
<span class="lineNum">    3109 </span>            :     //   1. There is no urgent need for it.
<span class="lineNum">    3110 </span>            :     //   2. It's a bit involved to make the errno variable thread-safe on
<span class="lineNum">    3111 </span>            :     //      all three operating systems (Linux, Windows, and Mac OS).
<span class="lineNum">    3112 </span>            :     //   3. To interpret the meaning of errno in a thread-safe way,
<span class="lineNum">    3113 </span>            :     //      we need the strerror_r() function, which is not available on
<span class="lineNum">    3114 </span>            :     //      Windows.
<span class="lineNum">    3115 </span><span class="lineNoCov">          0 :     fprintf(stderr,</span>
<span class="lineNum">    3116 </span>            :             &quot;Unable to open file \&quot;%s\&quot;\n&quot;,
<span class="lineNum">    3117 </span><span class="lineNoCov">          0 :             output_file_.c_str());</span>
<span class="lineNum">    3118 </span><span class="lineNoCov">          0 :     fflush(stderr);</span>
<span class="lineNum">    3119 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    3120 </span>            :   }
<span class="lineNum">    3121 </span><span class="lineNoCov">          0 :   std::stringstream stream;</span>
<span class="lineNum">    3122 </span><span class="lineNoCov">          0 :   PrintXmlUnitTest(&amp;stream, unit_test);</span>
<span class="lineNum">    3123 </span><span class="lineNoCov">          0 :   fprintf(xmlout, &quot;%s&quot;, StringStreamToString(&amp;stream).c_str());</span>
<span class="lineNum">    3124 </span><span class="lineNoCov">          0 :   fclose(xmlout);</span>
<span class="lineNum">    3125 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3126 </span>            : 
<span class="lineNum">    3127 </span>            : // Returns an XML-escaped copy of the input string str.  If is_attribute
<span class="lineNum">    3128 </span>            : // is true, the text is meant to appear as an attribute value, and
<span class="lineNum">    3129 </span>            : // normalizable whitespace is preserved by replacing it with character
<span class="lineNum">    3130 </span>            : // references.
<span class="lineNum">    3131 </span>            : //
<span class="lineNum">    3132 </span>            : // Invalid XML characters in str, if any, are stripped from the output.
<span class="lineNum">    3133 </span>            : // It is expected that most, if not all, of the text processed by this
<span class="lineNum">    3134 </span>            : // module will consist of ordinary English text.
<span class="lineNum">    3135 </span>            : // If this module is ever modified to produce version 1.1 XML output,
<span class="lineNum">    3136 </span>            : // most invalid characters can be retained using character references.
<a name="3137"><span class="lineNum">    3137 </span>            : // TODO(wan): It might be nice to have a minimally invasive, human-readable</a>
<span class="lineNum">    3138 </span>            : // escaping scheme for invalid characters, rather than dropping them.
<span class="lineNum">    3139 </span><span class="lineNoCov">          0 : std::string XmlUnitTestResultPrinter::EscapeXml(</span>
<span class="lineNum">    3140 </span>            :     const std::string&amp; str, bool is_attribute) {
<span class="lineNum">    3141 </span><span class="lineNoCov">          0 :   Message m;</span>
<span class="lineNum">    3142 </span>            : 
<span class="lineNum">    3143 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; str.size(); ++i) {</span>
<span class="lineNum">    3144 </span><span class="lineNoCov">          0 :     const char ch = str[i];</span>
<span class="lineNum">    3145 </span><span class="lineNoCov">          0 :     switch (ch) {</span>
<span class="lineNum">    3146 </span>            :       case '&lt;':
<span class="lineNum">    3147 </span><span class="lineNoCov">          0 :         m &lt;&lt; &quot;&amp;lt;&quot;;</span>
<span class="lineNum">    3148 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3149 </span>            :       case '&gt;':
<span class="lineNum">    3150 </span><span class="lineNoCov">          0 :         m &lt;&lt; &quot;&amp;gt;&quot;;</span>
<span class="lineNum">    3151 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3152 </span>            :       case '&amp;':
<span class="lineNum">    3153 </span><span class="lineNoCov">          0 :         m &lt;&lt; &quot;&amp;amp;&quot;;</span>
<span class="lineNum">    3154 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3155 </span>            :       case '\'':
<span class="lineNum">    3156 </span><span class="lineNoCov">          0 :         if (is_attribute)</span>
<span class="lineNum">    3157 </span><span class="lineNoCov">          0 :           m &lt;&lt; &quot;&amp;apos;&quot;;</span>
<span class="lineNum">    3158 </span>            :         else
<span class="lineNum">    3159 </span><span class="lineNoCov">          0 :           m &lt;&lt; '\'';</span>
<span class="lineNum">    3160 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3161 </span>            :       case '&quot;':
<span class="lineNum">    3162 </span><span class="lineNoCov">          0 :         if (is_attribute)</span>
<span class="lineNum">    3163 </span><span class="lineNoCov">          0 :           m &lt;&lt; &quot;&amp;quot;&quot;;</span>
<span class="lineNum">    3164 </span>            :         else
<span class="lineNum">    3165 </span><span class="lineNoCov">          0 :           m &lt;&lt; '&quot;';</span>
<span class="lineNum">    3166 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3167 </span>            :       default:
<span class="lineNum">    3168 </span><span class="lineNoCov">          0 :         if (IsValidXmlCharacter(ch)) {</span>
<span class="lineNum">    3169 </span><span class="lineNoCov">          0 :           if (is_attribute &amp;&amp; IsNormalizableWhitespace(ch))</span>
<span class="lineNum">    3170 </span><span class="lineNoCov">          0 :             m &lt;&lt; &quot;&amp;#x&quot; &lt;&lt; String::FormatByte(static_cast&lt;unsigned char&gt;(ch))</span>
<span class="lineNum">    3171 </span><span class="lineNoCov">          0 :               &lt;&lt; &quot;;&quot;;</span>
<span class="lineNum">    3172 </span>            :           else
<span class="lineNum">    3173 </span><span class="lineNoCov">          0 :             m &lt;&lt; ch;</span>
<span class="lineNum">    3174 </span>            :         }
<span class="lineNum">    3175 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3176 </span>            :     }
<span class="lineNum">    3177 </span>            :   }
<span class="lineNum">    3178 </span>            : 
<span class="lineNum">    3179 </span><span class="lineNoCov">          0 :   return m.GetString();</span>
<span class="lineNum">    3180 </span>            : }
<span class="lineNum">    3181 </span>            : 
<span class="lineNum">    3182 </span>            : // Returns the given string with all characters invalid in XML removed.
<a name="3183"><span class="lineNum">    3183 </span>            : // Currently invalid characters are dropped from the string. An</a>
<span class="lineNum">    3184 </span>            : // alternative is to replace them with certain characters such as . or ?.
<span class="lineNum">    3185 </span><span class="lineNoCov">          0 : std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(</span>
<span class="lineNum">    3186 </span>            :     const std::string&amp; str) {
<span class="lineNum">    3187 </span><span class="lineNoCov">          0 :   std::string output;</span>
<span class="lineNum">    3188 </span><span class="lineNoCov">          0 :   output.reserve(str.size());</span>
<span class="lineNum">    3189 </span><span class="lineNoCov">          0 :   for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)</span>
<span class="lineNum">    3190 </span><span class="lineNoCov">          0 :     if (IsValidXmlCharacter(*it))</span>
<span class="lineNum">    3191 </span><span class="lineNoCov">          0 :       output.push_back(*it);</span>
<span class="lineNum">    3192 </span>            : 
<span class="lineNum">    3193 </span><span class="lineNoCov">          0 :   return output;</span>
<span class="lineNum">    3194 </span>            : }
<span class="lineNum">    3195 </span>            : 
<span class="lineNum">    3196 </span>            : // The following routines generate an XML representation of a UnitTest
<span class="lineNum">    3197 </span>            : // object.
<span class="lineNum">    3198 </span>            : //
<span class="lineNum">    3199 </span>            : // This is how Google Test concepts map to the DTD:
<span class="lineNum">    3200 </span>            : //
<span class="lineNum">    3201 </span>            : // &lt;testsuites name=&quot;AllTests&quot;&gt;        &lt;-- corresponds to a UnitTest object
<span class="lineNum">    3202 </span>            : //   &lt;testsuite name=&quot;testcase-name&quot;&gt;  &lt;-- corresponds to a TestCase object
<span class="lineNum">    3203 </span>            : //     &lt;testcase name=&quot;test-name&quot;&gt;     &lt;-- corresponds to a TestInfo object
<span class="lineNum">    3204 </span>            : //       &lt;failure message=&quot;...&quot;&gt;...&lt;/failure&gt;
<span class="lineNum">    3205 </span>            : //       &lt;failure message=&quot;...&quot;&gt;...&lt;/failure&gt;
<span class="lineNum">    3206 </span>            : //       &lt;failure message=&quot;...&quot;&gt;...&lt;/failure&gt;
<span class="lineNum">    3207 </span>            : //                                     &lt;-- individual assertion failures
<span class="lineNum">    3208 </span>            : //     &lt;/testcase&gt;
<span class="lineNum">    3209 </span>            : //   &lt;/testsuite&gt;
<span class="lineNum">    3210 </span>            : // &lt;/testsuites&gt;
<a name="3211"><span class="lineNum">    3211 </span>            : </a>
<span class="lineNum">    3212 </span>            : // Formats the given time in milliseconds as seconds.
<span class="lineNum">    3213 </span><span class="lineNoCov">          0 : std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {</span>
<span class="lineNum">    3214 </span><span class="lineNoCov">          0 :   ::std::stringstream ss;</span>
<span class="lineNum">    3215 </span><span class="lineNoCov">          0 :   ss &lt;&lt; ms/1000.0;</span>
<span class="lineNum">    3216 </span><span class="lineNoCov">          0 :   return ss.str();</span>
<span class="lineNum">    3217 </span>            : }
<span class="lineNum">    3218 </span>            : 
<a name="3219"><span class="lineNum">    3219 </span>            : // Converts the given epoch time in milliseconds to a date string in the ISO</a>
<span class="lineNum">    3220 </span>            : // 8601 format, without the timezone information.
<span class="lineNum">    3221 </span><span class="lineNoCov">          0 : std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {</span>
<span class="lineNum">    3222 </span>            :   // Using non-reentrant version as localtime_r is not portable.
<span class="lineNum">    3223 </span><span class="lineNoCov">          0 :   time_t seconds = static_cast&lt;time_t&gt;(ms / 1000);</span>
<span class="lineNum">    3224 </span>            : #ifdef _MSC_VER
<span class="lineNum">    3225 </span>            : # pragma warning(push)          // Saves the current warning state.
<span class="lineNum">    3226 </span>            : # pragma warning(disable:4996)  // Temporarily disables warning 4996
<span class="lineNum">    3227 </span>            :                                 // (function or variable may be unsafe).
<span class="lineNum">    3228 </span>            :   const struct tm* const time_struct = localtime(&amp;seconds);  // NOLINT
<span class="lineNum">    3229 </span>            : # pragma warning(pop)           // Restores the warning state again.
<span class="lineNum">    3230 </span>            : #else
<span class="lineNum">    3231 </span><span class="lineNoCov">          0 :   const struct tm* const time_struct = localtime(&amp;seconds);  // NOLINT</span>
<span class="lineNum">    3232 </span>            : #endif
<span class="lineNum">    3233 </span><span class="lineNoCov">          0 :   if (time_struct == NULL)</span>
<span class="lineNum">    3234 </span><span class="lineNoCov">          0 :     return &quot;&quot;;  // Invalid ms value</span>
<span class="lineNum">    3235 </span>            : 
<span class="lineNum">    3236 </span>            :   // YYYY-MM-DDThh:mm:ss
<span class="lineNum">    3237 </span><span class="lineNoCov">          0 :   return StreamableToString(time_struct-&gt;tm_year + 1900) + &quot;-&quot; +</span>
<span class="lineNum">    3238 </span><span class="lineNoCov">          0 :       String::FormatIntWidth2(time_struct-&gt;tm_mon + 1) + &quot;-&quot; +</span>
<span class="lineNum">    3239 </span><span class="lineNoCov">          0 :       String::FormatIntWidth2(time_struct-&gt;tm_mday) + &quot;T&quot; +</span>
<span class="lineNum">    3240 </span><span class="lineNoCov">          0 :       String::FormatIntWidth2(time_struct-&gt;tm_hour) + &quot;:&quot; +</span>
<span class="lineNum">    3241 </span><span class="lineNoCov">          0 :       String::FormatIntWidth2(time_struct-&gt;tm_min) + &quot;:&quot; +</span>
<span class="lineNum">    3242 </span><span class="lineNoCov">          0 :       String::FormatIntWidth2(time_struct-&gt;tm_sec);</span>
<span class="lineNum">    3243 </span>            : }
<a name="3244"><span class="lineNum">    3244 </span>            : </a>
<span class="lineNum">    3245 </span>            : // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
<span class="lineNum">    3246 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,</span>
<span class="lineNum">    3247 </span>            :                                                      const char* data) {
<span class="lineNum">    3248 </span><span class="lineNoCov">          0 :   const char* segment = data;</span>
<span class="lineNum">    3249 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;&lt;![CDATA[&quot;;</span>
<span class="lineNum">    3250 </span><span class="lineNoCov">          0 :   for (;;) {</span>
<span class="lineNum">    3251 </span><span class="lineNoCov">          0 :     const char* const next_segment = strstr(segment, &quot;]]&gt;&quot;);</span>
<span class="lineNum">    3252 </span><span class="lineNoCov">          0 :     if (next_segment != NULL) {</span>
<span class="lineNum">    3253 </span>            :       stream-&gt;write(
<span class="lineNum">    3254 </span><span class="lineNoCov">          0 :           segment, static_cast&lt;std::streamsize&gt;(next_segment - segment));</span>
<span class="lineNum">    3255 </span><span class="lineNoCov">          0 :       *stream &lt;&lt; &quot;]]&gt;]]&amp;gt;&lt;![CDATA[&quot;;</span>
<span class="lineNum">    3256 </span><span class="lineNoCov">          0 :       segment = next_segment + strlen(&quot;]]&gt;&quot;);</span>
<span class="lineNum">    3257 </span>            :     } else {
<span class="lineNum">    3258 </span><span class="lineNoCov">          0 :       *stream &lt;&lt; segment;</span>
<span class="lineNum">    3259 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">    3260 </span>            :     }
<span class="lineNum">    3261 </span>            :   }
<span class="lineNum">    3262 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;]]&gt;&quot;;</span>
<a name="3263"><span class="lineNum">    3263 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    3264 </span>            : 
<span class="lineNum">    3265 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::OutputXmlAttribute(</span>
<span class="lineNum">    3266 </span>            :     std::ostream* stream,
<span class="lineNum">    3267 </span>            :     const std::string&amp; element_name,
<span class="lineNum">    3268 </span>            :     const std::string&amp; name,
<span class="lineNum">    3269 </span>            :     const std::string&amp; value) {
<span class="lineNum">    3270 </span>            :   const std::vector&lt;std::string&gt;&amp; allowed_names =
<span class="lineNum">    3271 </span><span class="lineNoCov">          0 :       GetReservedAttributesForElement(element_name);</span>
<span class="lineNum">    3272 </span>            : 
<span class="lineNum">    3273 </span><span class="lineNoCov">          0 :   GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=</span>
<span class="lineNum">    3274 </span>            :                    allowed_names.end())
<span class="lineNum">    3275 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Attribute &quot; &lt;&lt; name &lt;&lt; &quot; is not allowed for element &lt;&quot; &lt;&lt; element_name</span>
<span class="lineNum">    3276 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;&gt;.&quot;;</span>
<span class="lineNum">    3277 </span>            : 
<span class="lineNum">    3278 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot; &quot; &lt;&lt; name &lt;&lt; &quot;=\&quot;&quot; &lt;&lt; EscapeXmlAttribute(value) &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    3279 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3280 </span>            : 
<a name="3281"><span class="lineNum">    3281 </span>            : // Prints an XML representation of a TestInfo object.</a>
<span class="lineNum">    3282 </span>            : // TODO(wan): There is also value in printing properties with the plain printer.
<span class="lineNum">    3283 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,</span>
<span class="lineNum">    3284 </span>            :                                                  const char* test_case_name,
<span class="lineNum">    3285 </span>            :                                                  const TestInfo&amp; test_info) {
<span class="lineNum">    3286 </span><span class="lineNoCov">          0 :   const TestResult&amp; result = *test_info.result();</span>
<span class="lineNum">    3287 </span><span class="lineNoCov">          0 :   const std::string kTestcase = &quot;testcase&quot;;</span>
<span class="lineNum">    3288 </span>            : 
<span class="lineNum">    3289 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;    &lt;testcase&quot;;</span>
<span class="lineNum">    3290 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestcase, &quot;name&quot;, test_info.name());</span>
<span class="lineNum">    3291 </span>            : 
<span class="lineNum">    3292 </span><span class="lineNoCov">          0 :   if (test_info.value_param() != NULL) {</span>
<span class="lineNum">    3293 </span><span class="lineNoCov">          0 :     OutputXmlAttribute(stream, kTestcase, &quot;value_param&quot;,</span>
<span class="lineNum">    3294 </span><span class="lineNoCov">          0 :                        test_info.value_param());</span>
<span class="lineNum">    3295 </span>            :   }
<span class="lineNum">    3296 </span><span class="lineNoCov">          0 :   if (test_info.type_param() != NULL) {</span>
<span class="lineNum">    3297 </span><span class="lineNoCov">          0 :     OutputXmlAttribute(stream, kTestcase, &quot;type_param&quot;, test_info.type_param());</span>
<span class="lineNum">    3298 </span>            :   }
<span class="lineNum">    3299 </span>            : 
<span class="lineNum">    3300 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestcase, &quot;status&quot;,</span>
<span class="lineNum">    3301 </span><span class="lineNoCov">          0 :                      test_info.should_run() ? &quot;run&quot; : &quot;notrun&quot;);</span>
<span class="lineNum">    3302 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestcase, &quot;time&quot;,</span>
<span class="lineNum">    3303 </span><span class="lineNoCov">          0 :                      FormatTimeInMillisAsSeconds(result.elapsed_time()));</span>
<span class="lineNum">    3304 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestcase, &quot;classname&quot;, test_case_name);</span>
<span class="lineNum">    3305 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; TestPropertiesAsXmlAttributes(result);</span>
<span class="lineNum">    3306 </span>            : 
<span class="lineNum">    3307 </span><span class="lineNoCov">          0 :   int failures = 0;</span>
<span class="lineNum">    3308 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; result.total_part_count(); ++i) {</span>
<span class="lineNum">    3309 </span><span class="lineNoCov">          0 :     const TestPartResult&amp; part = result.GetTestPartResult(i);</span>
<span class="lineNum">    3310 </span><span class="lineNoCov">          0 :     if (part.failed()) {</span>
<span class="lineNum">    3311 </span><span class="lineNoCov">          0 :       if (++failures == 1) {</span>
<span class="lineNum">    3312 </span><span class="lineNoCov">          0 :         *stream &lt;&lt; &quot;&gt;\n&quot;;</span>
<span class="lineNum">    3313 </span>            :       }
<span class="lineNum">    3314 </span>            :       const string location = internal::FormatCompilerIndependentFileLocation(
<span class="lineNum">    3315 </span><span class="lineNoCov">          0 :           part.file_name(), part.line_number());</span>
<span class="lineNum">    3316 </span><span class="lineNoCov">          0 :       const string summary = location + &quot;\n&quot; + part.summary();</span>
<span class="lineNum">    3317 </span><span class="lineNoCov">          0 :       *stream &lt;&lt; &quot;      &lt;failure message=\&quot;&quot;</span>
<span class="lineNum">    3318 </span><span class="lineNoCov">          0 :               &lt;&lt; EscapeXmlAttribute(summary.c_str())</span>
<span class="lineNum">    3319 </span><span class="lineNoCov">          0 :               &lt;&lt; &quot;\&quot; type=\&quot;\&quot;&gt;&quot;;</span>
<span class="lineNum">    3320 </span><span class="lineNoCov">          0 :       const string detail = location + &quot;\n&quot; + part.message();</span>
<span class="lineNum">    3321 </span><span class="lineNoCov">          0 :       OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());</span>
<span class="lineNum">    3322 </span><span class="lineNoCov">          0 :       *stream &lt;&lt; &quot;&lt;/failure&gt;\n&quot;;</span>
<span class="lineNum">    3323 </span>            :     }
<span class="lineNum">    3324 </span>            :   }
<span class="lineNum">    3325 </span>            : 
<span class="lineNum">    3326 </span><span class="lineNoCov">          0 :   if (failures == 0)</span>
<span class="lineNum">    3327 </span><span class="lineNoCov">          0 :     *stream &lt;&lt; &quot; /&gt;\n&quot;;</span>
<span class="lineNum">    3328 </span>            :   else
<span class="lineNum">    3329 </span><span class="lineNoCov">          0 :     *stream &lt;&lt; &quot;    &lt;/testcase&gt;\n&quot;;</span>
<span class="lineNum">    3330 </span><span class="lineNoCov">          0 : }</span>
<a name="3331"><span class="lineNum">    3331 </span>            : </a>
<span class="lineNum">    3332 </span>            : // Prints an XML representation of a TestCase object
<span class="lineNum">    3333 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,</span>
<span class="lineNum">    3334 </span>            :                                                 const TestCase&amp; test_case) {
<span class="lineNum">    3335 </span><span class="lineNoCov">          0 :   const std::string kTestsuite = &quot;testsuite&quot;;</span>
<span class="lineNum">    3336 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;  &lt;&quot; &lt;&lt; kTestsuite;</span>
<span class="lineNum">    3337 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuite, &quot;name&quot;, test_case.name());</span>
<span class="lineNum">    3338 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuite, &quot;tests&quot;,</span>
<span class="lineNum">    3339 </span><span class="lineNoCov">          0 :                      StreamableToString(test_case.reportable_test_count()));</span>
<span class="lineNum">    3340 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuite, &quot;failures&quot;,</span>
<span class="lineNum">    3341 </span><span class="lineNoCov">          0 :                      StreamableToString(test_case.failed_test_count()));</span>
<span class="lineNum">    3342 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(</span>
<span class="lineNum">    3343 </span>            :       stream, kTestsuite, &quot;disabled&quot;,
<span class="lineNum">    3344 </span><span class="lineNoCov">          0 :       StreamableToString(test_case.reportable_disabled_test_count()));</span>
<span class="lineNum">    3345 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuite, &quot;errors&quot;, &quot;0&quot;);</span>
<span class="lineNum">    3346 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuite, &quot;time&quot;,</span>
<span class="lineNum">    3347 </span><span class="lineNoCov">          0 :                      FormatTimeInMillisAsSeconds(test_case.elapsed_time()));</span>
<span class="lineNum">    3348 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())</span>
<span class="lineNum">    3349 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot;&gt;\n&quot;;</span>
<span class="lineNum">    3350 </span>            : 
<span class="lineNum">    3351 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; test_case.total_test_count(); ++i) {</span>
<span class="lineNum">    3352 </span><span class="lineNoCov">          0 :     if (test_case.GetTestInfo(i)-&gt;is_reportable())</span>
<span class="lineNum">    3353 </span><span class="lineNoCov">          0 :       OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));</span>
<span class="lineNum">    3354 </span>            :   }
<span class="lineNum">    3355 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;  &lt;/&quot; &lt;&lt; kTestsuite &lt;&lt; &quot;&gt;\n&quot;;</span>
<span class="lineNum">    3356 </span><span class="lineNoCov">          0 : }</span>
<a name="3357"><span class="lineNum">    3357 </span>            : </a>
<span class="lineNum">    3358 </span>            : // Prints an XML summary of unit_test to output stream out.
<span class="lineNum">    3359 </span><span class="lineNoCov">          0 : void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,</span>
<span class="lineNum">    3360 </span>            :                                                 const UnitTest&amp; unit_test) {
<span class="lineNum">    3361 </span><span class="lineNoCov">          0 :   const std::string kTestsuites = &quot;testsuites&quot;;</span>
<span class="lineNum">    3362 </span>            : 
<span class="lineNum">    3363 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\n&quot;;</span>
<span class="lineNum">    3364 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;&lt;&quot; &lt;&lt; kTestsuites;</span>
<span class="lineNum">    3365 </span>            : 
<span class="lineNum">    3366 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuites, &quot;tests&quot;,</span>
<span class="lineNum">    3367 </span><span class="lineNoCov">          0 :                      StreamableToString(unit_test.reportable_test_count()));</span>
<span class="lineNum">    3368 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuites, &quot;failures&quot;,</span>
<span class="lineNum">    3369 </span><span class="lineNoCov">          0 :                      StreamableToString(unit_test.failed_test_count()));</span>
<span class="lineNum">    3370 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(</span>
<span class="lineNum">    3371 </span>            :       stream, kTestsuites, &quot;disabled&quot;,
<span class="lineNum">    3372 </span><span class="lineNoCov">          0 :       StreamableToString(unit_test.reportable_disabled_test_count()));</span>
<span class="lineNum">    3373 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuites, &quot;errors&quot;, &quot;0&quot;);</span>
<span class="lineNum">    3374 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(</span>
<span class="lineNum">    3375 </span>            :       stream, kTestsuites, &quot;timestamp&quot;,
<span class="lineNum">    3376 </span><span class="lineNoCov">          0 :       FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));</span>
<span class="lineNum">    3377 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuites, &quot;time&quot;,</span>
<span class="lineNum">    3378 </span><span class="lineNoCov">          0 :                      FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));</span>
<span class="lineNum">    3379 </span>            : 
<span class="lineNum">    3380 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(shuffle)) {</span>
<span class="lineNum">    3381 </span><span class="lineNoCov">          0 :     OutputXmlAttribute(stream, kTestsuites, &quot;random_seed&quot;,</span>
<span class="lineNum">    3382 </span><span class="lineNoCov">          0 :                        StreamableToString(unit_test.random_seed()));</span>
<span class="lineNum">    3383 </span>            :   }
<span class="lineNum">    3384 </span>            : 
<span class="lineNum">    3385 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());</span>
<span class="lineNum">    3386 </span>            : 
<span class="lineNum">    3387 </span><span class="lineNoCov">          0 :   OutputXmlAttribute(stream, kTestsuites, &quot;name&quot;, &quot;AllTests&quot;);</span>
<span class="lineNum">    3388 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;&gt;\n&quot;;</span>
<span class="lineNum">    3389 </span>            : 
<span class="lineNum">    3390 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; unit_test.total_test_case_count(); ++i) {</span>
<span class="lineNum">    3391 </span><span class="lineNoCov">          0 :     if (unit_test.GetTestCase(i)-&gt;reportable_test_count() &gt; 0)</span>
<span class="lineNum">    3392 </span><span class="lineNoCov">          0 :       PrintXmlTestCase(stream, *unit_test.GetTestCase(i));</span>
<span class="lineNum">    3393 </span>            :   }
<span class="lineNum">    3394 </span><span class="lineNoCov">          0 :   *stream &lt;&lt; &quot;&lt;/&quot; &lt;&lt; kTestsuites &lt;&lt; &quot;&gt;\n&quot;;</span>
<span class="lineNum">    3395 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3396 </span>            : 
<a name="3397"><span class="lineNum">    3397 </span>            : // Produces a string representing the test properties in a result as space</a>
<span class="lineNum">    3398 </span>            : // delimited XML attributes based on the property key=&quot;value&quot; pairs.
<span class="lineNum">    3399 </span><span class="lineNoCov">          0 : std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(</span>
<span class="lineNum">    3400 </span>            :     const TestResult&amp; result) {
<span class="lineNum">    3401 </span><span class="lineNoCov">          0 :   Message attributes;</span>
<span class="lineNum">    3402 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; result.test_property_count(); ++i) {</span>
<span class="lineNum">    3403 </span><span class="lineNoCov">          0 :     const TestProperty&amp; property = result.GetTestProperty(i);</span>
<span class="lineNum">    3404 </span><span class="lineNoCov">          0 :     attributes &lt;&lt; &quot; &quot; &lt;&lt; property.key() &lt;&lt; &quot;=&quot;</span>
<span class="lineNum">    3405 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;\&quot;&quot; &lt;&lt; EscapeXmlAttribute(property.value()) &lt;&lt; &quot;\&quot;&quot;;</span>
<span class="lineNum">    3406 </span>            :   }
<span class="lineNum">    3407 </span><span class="lineNoCov">          0 :   return attributes.GetString();</span>
<span class="lineNum">    3408 </span>            : }
<span class="lineNum">    3409 </span>            : 
<span class="lineNum">    3410 </span>            : // End XmlUnitTestResultPrinter
<span class="lineNum">    3411 </span>            : 
<span class="lineNum">    3412 </span>            : #if GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    3413 </span>            : 
<span class="lineNum">    3414 </span>            : // Checks if str contains '=', '&amp;', '%' or '\n' characters. If yes,
<span class="lineNum">    3415 </span>            : // replaces them by &quot;%xx&quot; where xx is their hexadecimal value. For
<span class="lineNum">    3416 </span>            : // example, replaces &quot;=&quot; with &quot;%3D&quot;.  This algorithm is O(strlen(str))
<a name="3417"><span class="lineNum">    3417 </span>            : // in both time and space -- important as the input str may contain an</a>
<span class="lineNum">    3418 </span>            : // arbitrarily long test failure message and stack trace.
<span class="lineNum">    3419 </span><span class="lineNoCov">          0 : string StreamingListener::UrlEncode(const char* str) {</span>
<span class="lineNum">    3420 </span><span class="lineNoCov">          0 :   string result;</span>
<span class="lineNum">    3421 </span><span class="lineNoCov">          0 :   result.reserve(strlen(str) + 1);</span>
<span class="lineNum">    3422 </span><span class="lineNoCov">          0 :   for (char ch = *str; ch != '\0'; ch = *++str) {</span>
<span class="lineNum">    3423 </span><span class="lineNoCov">          0 :     switch (ch) {</span>
<span class="lineNum">    3424 </span>            :       case '%':
<span class="lineNum">    3425 </span>            :       case '=':
<span class="lineNum">    3426 </span>            :       case '&amp;':
<span class="lineNum">    3427 </span>            :       case '\n':
<span class="lineNum">    3428 </span><span class="lineNoCov">          0 :         result.append(&quot;%&quot; + String::FormatByte(static_cast&lt;unsigned char&gt;(ch)));</span>
<span class="lineNum">    3429 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3430 </span>            :       default:
<span class="lineNum">    3431 </span><span class="lineNoCov">          0 :         result.push_back(ch);</span>
<span class="lineNum">    3432 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    3433 </span>            :     }
<span class="lineNum">    3434 </span>            :   }
<span class="lineNum">    3435 </span><span class="lineNoCov">          0 :   return result;</span>
<a name="3436"><span class="lineNum">    3436 </span>            : }</a>
<span class="lineNum">    3437 </span>            : 
<span class="lineNum">    3438 </span><span class="lineNoCov">          0 : void StreamingListener::SocketWriter::MakeConnection() {</span>
<span class="lineNum">    3439 </span><span class="lineNoCov">          0 :   GTEST_CHECK_(sockfd_ == -1)</span>
<span class="lineNum">    3440 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;MakeConnection() can't be called when there is already a connection.&quot;;</span>
<span class="lineNum">    3441 </span>            : 
<span class="lineNum">    3442 </span>            :   addrinfo hints;
<span class="lineNum">    3443 </span><span class="lineNoCov">          0 :   memset(&amp;hints, 0, sizeof(hints));</span>
<span class="lineNum">    3444 </span><span class="lineNoCov">          0 :   hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.</span>
<span class="lineNum">    3445 </span><span class="lineNoCov">          0 :   hints.ai_socktype = SOCK_STREAM;</span>
<span class="lineNum">    3446 </span><span class="lineNoCov">          0 :   addrinfo* servinfo = NULL;</span>
<span class="lineNum">    3447 </span>            : 
<span class="lineNum">    3448 </span>            :   // Use the getaddrinfo() to get a linked list of IP addresses for
<span class="lineNum">    3449 </span>            :   // the given host name.
<span class="lineNum">    3450 </span><span class="lineNoCov">          0 :   const int error_num = getaddrinfo(</span>
<span class="lineNum">    3451 </span><span class="lineNoCov">          0 :       host_name_.c_str(), port_num_.c_str(), &amp;hints, &amp;servinfo);</span>
<span class="lineNum">    3452 </span><span class="lineNoCov">          0 :   if (error_num != 0) {</span>
<span class="lineNum">    3453 </span><span class="lineNoCov">          0 :     GTEST_LOG_(WARNING) &lt;&lt; &quot;stream_result_to: getaddrinfo() failed: &quot;</span>
<span class="lineNum">    3454 </span><span class="lineNoCov">          0 :                         &lt;&lt; gai_strerror(error_num);</span>
<span class="lineNum">    3455 </span>            :   }
<span class="lineNum">    3456 </span>            : 
<span class="lineNum">    3457 </span>            :   // Loop through all the results and connect to the first we can.
<span class="lineNum">    3458 </span><span class="lineNoCov">          0 :   for (addrinfo* cur_addr = servinfo; sockfd_ == -1 &amp;&amp; cur_addr != NULL;</span>
<span class="lineNum">    3459 </span>            :        cur_addr = cur_addr-&gt;ai_next) {
<span class="lineNum">    3460 </span><span class="lineNoCov">          0 :     sockfd_ = socket(</span>
<span class="lineNum">    3461 </span><span class="lineNoCov">          0 :         cur_addr-&gt;ai_family, cur_addr-&gt;ai_socktype, cur_addr-&gt;ai_protocol);</span>
<span class="lineNum">    3462 </span><span class="lineNoCov">          0 :     if (sockfd_ != -1) {</span>
<span class="lineNum">    3463 </span>            :       // Connect the client socket to the server socket.
<span class="lineNum">    3464 </span><span class="lineNoCov">          0 :       if (connect(sockfd_, cur_addr-&gt;ai_addr, cur_addr-&gt;ai_addrlen) == -1) {</span>
<span class="lineNum">    3465 </span><span class="lineNoCov">          0 :         close(sockfd_);</span>
<span class="lineNum">    3466 </span><span class="lineNoCov">          0 :         sockfd_ = -1;</span>
<span class="lineNum">    3467 </span>            :       }
<span class="lineNum">    3468 </span>            :     }
<span class="lineNum">    3469 </span>            :   }
<span class="lineNum">    3470 </span>            : 
<span class="lineNum">    3471 </span><span class="lineNoCov">          0 :   freeaddrinfo(servinfo);  // all done with this structure</span>
<span class="lineNum">    3472 </span>            : 
<span class="lineNum">    3473 </span><span class="lineNoCov">          0 :   if (sockfd_ == -1) {</span>
<span class="lineNum">    3474 </span><span class="lineNoCov">          0 :     GTEST_LOG_(WARNING) &lt;&lt; &quot;stream_result_to: failed to connect to &quot;</span>
<span class="lineNum">    3475 </span><span class="lineNoCov">          0 :                         &lt;&lt; host_name_ &lt;&lt; &quot;:&quot; &lt;&lt; port_num_;</span>
<span class="lineNum">    3476 </span>            :   }
<span class="lineNum">    3477 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3478 </span>            : 
<span class="lineNum">    3479 </span>            : // End of class Streaming Listener
<span class="lineNum">    3480 </span>            : #endif  // GTEST_CAN_STREAM_RESULTS__
<span class="lineNum">    3481 </span>            : 
<span class="lineNum">    3482 </span>            : // Class ScopedTrace
<span class="lineNum">    3483 </span>            : 
<a name="3484"><span class="lineNum">    3484 </span>            : // Pushes the given source file location and message onto a per-thread</a>
<span class="lineNum">    3485 </span>            : // trace stack maintained by Google Test.
<span class="lineNum">    3486 </span><span class="lineNoCov">          0 : ScopedTrace::ScopedTrace(const char* file, int line, const Message&amp; message)</span>
<span class="lineNum">    3487 </span>            :     GTEST_LOCK_EXCLUDED_(&amp;UnitTest::mutex_) {
<span class="lineNum">    3488 </span><span class="lineNoCov">          0 :   TraceInfo trace;</span>
<span class="lineNum">    3489 </span><span class="lineNoCov">          0 :   trace.file = file;</span>
<span class="lineNum">    3490 </span><span class="lineNoCov">          0 :   trace.line = line;</span>
<span class="lineNum">    3491 </span><span class="lineNoCov">          0 :   trace.message = message.GetString();</span>
<span class="lineNum">    3492 </span>            : 
<span class="lineNum">    3493 </span><span class="lineNoCov">          0 :   UnitTest::GetInstance()-&gt;PushGTestTrace(trace);</span>
<span class="lineNum">    3494 </span><span class="lineNoCov">          0 : }</span>
<a name="3495"><span class="lineNum">    3495 </span>            : </a>
<span class="lineNum">    3496 </span>            : // Pops the info pushed by the c'tor.
<span class="lineNum">    3497 </span><span class="lineNoCov">          0 : ScopedTrace::~ScopedTrace()</span>
<span class="lineNum">    3498 </span>            :     GTEST_LOCK_EXCLUDED_(&amp;UnitTest::mutex_) {
<span class="lineNum">    3499 </span><span class="lineNoCov">          0 :   UnitTest::GetInstance()-&gt;PopGTestTrace();</span>
<span class="lineNum">    3500 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3501 </span>            : 
<span class="lineNum">    3502 </span>            : 
<span class="lineNum">    3503 </span>            : // class OsStackTraceGetter
<span class="lineNum">    3504 </span>            : 
<span class="lineNum">    3505 </span>            : // Returns the current OS stack trace as an std::string.  Parameters:
<span class="lineNum">    3506 </span>            : //
<span class="lineNum">    3507 </span>            : //   max_depth  - the maximum number of stack frames to be included
<span class="lineNum">    3508 </span>            : //                in the trace.
<span class="lineNum">    3509 </span>            : //   skip_count - the number of top frames to be skipped; doesn't count
<a name="3510"><span class="lineNum">    3510 </span>            : //                against max_depth.</a>
<span class="lineNum">    3511 </span>            : //
<span class="lineNum">    3512 </span><span class="lineNoCov">          0 : string OsStackTraceGetter::CurrentStackTrace(int /* max_depth */,</span>
<span class="lineNum">    3513 </span>            :                                              int /* skip_count */)
<span class="lineNum">    3514 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3515 </span><span class="lineNoCov">          0 :   return &quot;&quot;;</span>
<a name="3516"><span class="lineNum">    3516 </span>            : }</a>
<span class="lineNum">    3517 </span>            : 
<span class="lineNum">    3518 </span><span class="lineNoCov">          0 : void OsStackTraceGetter::UponLeavingGTest()</span>
<span class="lineNum">    3519 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3520 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3521 </span>            : 
<span class="lineNum">    3522 </span>            : const char* const
<span class="lineNum">    3523 </span>            : OsStackTraceGetter::kElidedFramesMarker =
<span class="lineNum">    3524 </span>            :     &quot;... &quot; GTEST_NAME_ &quot; internal frames ...&quot;;
<span class="lineNum">    3525 </span>            : 
<span class="lineNum">    3526 </span>            : // A helper class that creates the premature-exit file in its
<span class="lineNum">    3527 </span>            : // constructor and deletes the file in its destructor.
<a name="3528"><span class="lineNum">    3528 </span>            : class ScopedPrematureExitFile {</a>
<span class="lineNum">    3529 </span>            :  public:
<span class="lineNum">    3530 </span><span class="lineNoCov">          0 :   explicit ScopedPrematureExitFile(const char* premature_exit_filepath)</span>
<span class="lineNum">    3531 </span><span class="lineNoCov">          0 :       : premature_exit_filepath_(premature_exit_filepath) {</span>
<span class="lineNum">    3532 </span>            :     // If a path to the premature-exit file is specified...
<span class="lineNum">    3533 </span><span class="lineNoCov">          0 :     if (premature_exit_filepath != NULL &amp;&amp; *premature_exit_filepath != '\0') {</span>
<span class="lineNum">    3534 </span>            :       // create the file with a single &quot;0&quot; character in it.  I/O
<span class="lineNum">    3535 </span>            :       // errors are ignored as there's nothing better we can do and we
<span class="lineNum">    3536 </span>            :       // don't want to fail the test because of this.
<span class="lineNum">    3537 </span><span class="lineNoCov">          0 :       FILE* pfile = posix::FOpen(premature_exit_filepath, &quot;w&quot;);</span>
<span class="lineNum">    3538 </span><span class="lineNoCov">          0 :       fwrite(&quot;0&quot;, 1, 1, pfile);</span>
<span class="lineNum">    3539 </span><span class="lineNoCov">          0 :       fclose(pfile);</span>
<span class="lineNum">    3540 </span>            :     }
<a name="3541"><span class="lineNum">    3541 </span><span class="lineNoCov">          0 :   }</span></a>
<span class="lineNum">    3542 </span>            : 
<span class="lineNum">    3543 </span><span class="lineNoCov">          0 :   ~ScopedPrematureExitFile() {</span>
<span class="lineNum">    3544 </span><span class="lineNoCov">          0 :     if (premature_exit_filepath_ != NULL &amp;&amp; *premature_exit_filepath_ != '\0') {</span>
<span class="lineNum">    3545 </span><span class="lineNoCov">          0 :       remove(premature_exit_filepath_);</span>
<span class="lineNum">    3546 </span>            :     }
<span class="lineNum">    3547 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">    3548 </span>            : 
<span class="lineNum">    3549 </span>            :  private:
<span class="lineNum">    3550 </span>            :   const char* const premature_exit_filepath_;
<span class="lineNum">    3551 </span>            : 
<span class="lineNum">    3552 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
<span class="lineNum">    3553 </span>            : };
<span class="lineNum">    3554 </span>            : 
<span class="lineNum">    3555 </span>            : }  // namespace internal
<span class="lineNum">    3556 </span>            : 
<a name="3557"><span class="lineNum">    3557 </span>            : // class TestEventListeners</a>
<span class="lineNum">    3558 </span>            : 
<span class="lineNum">    3559 </span><span class="lineNoCov">          0 : TestEventListeners::TestEventListeners()</span>
<span class="lineNum">    3560 </span><span class="lineNoCov">          0 :     : repeater_(new internal::TestEventRepeater()),</span>
<span class="lineNum">    3561 </span>            :       default_result_printer_(NULL),
<span class="lineNum">    3562 </span><span class="lineNoCov">          0 :       default_xml_generator_(NULL) {</span>
<a name="3563"><span class="lineNum">    3563 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    3564 </span>            : 
<span class="lineNum">    3565 </span><span class="lineNoCov">          0 : TestEventListeners::~TestEventListeners() { delete repeater_; }</span>
<span class="lineNum">    3566 </span>            : 
<span class="lineNum">    3567 </span>            : // Returns the standard listener responsible for the default console
<span class="lineNum">    3568 </span>            : // output.  Can be removed from the listeners list to shut down default
<a name="3569"><span class="lineNum">    3569 </span>            : // console output.  Note that removing this object from the listener list</a>
<span class="lineNum">    3570 </span>            : // with Release transfers its ownership to the user.
<span class="lineNum">    3571 </span><span class="lineNoCov">          0 : void TestEventListeners::Append(TestEventListener* listener) {</span>
<span class="lineNum">    3572 </span><span class="lineNoCov">          0 :   repeater_-&gt;Append(listener);</span>
<span class="lineNum">    3573 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3574 </span>            : 
<span class="lineNum">    3575 </span>            : // Removes the given event listener from the list and returns it.  It then
<a name="3576"><span class="lineNum">    3576 </span>            : // becomes the caller's responsibility to delete the listener. Returns</a>
<span class="lineNum">    3577 </span>            : // NULL if the listener is not found in the list.
<span class="lineNum">    3578 </span><span class="lineNoCov">          0 : TestEventListener* TestEventListeners::Release(TestEventListener* listener) {</span>
<span class="lineNum">    3579 </span><span class="lineNoCov">          0 :   if (listener == default_result_printer_)</span>
<span class="lineNum">    3580 </span><span class="lineNoCov">          0 :     default_result_printer_ = NULL;</span>
<span class="lineNum">    3581 </span><span class="lineNoCov">          0 :   else if (listener == default_xml_generator_)</span>
<span class="lineNum">    3582 </span><span class="lineNoCov">          0 :     default_xml_generator_ = NULL;</span>
<span class="lineNum">    3583 </span><span class="lineNoCov">          0 :   return repeater_-&gt;Release(listener);</span>
<span class="lineNum">    3584 </span>            : }
<span class="lineNum">    3585 </span>            : 
<a name="3586"><span class="lineNum">    3586 </span>            : // Returns repeater that broadcasts the TestEventListener events to all</a>
<span class="lineNum">    3587 </span>            : // subscribers.
<span class="lineNum">    3588 </span><span class="lineNoCov">          0 : TestEventListener* TestEventListeners::repeater() { return repeater_; }</span>
<span class="lineNum">    3589 </span>            : 
<span class="lineNum">    3590 </span>            : // Sets the default_result_printer attribute to the provided listener.
<span class="lineNum">    3591 </span>            : // The listener is also added to the listener list and previous
<span class="lineNum">    3592 </span>            : // default_result_printer is removed from it and deleted. The listener can
<a name="3593"><span class="lineNum">    3593 </span>            : // also be NULL in which case it will not be added to the list. Does</a>
<span class="lineNum">    3594 </span>            : // nothing if the previous and the current listener objects are the same.
<span class="lineNum">    3595 </span><span class="lineNoCov">          0 : void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {</span>
<span class="lineNum">    3596 </span><span class="lineNoCov">          0 :   if (default_result_printer_ != listener) {</span>
<span class="lineNum">    3597 </span>            :     // It is an error to pass this method a listener that is already in the
<span class="lineNum">    3598 </span>            :     // list.
<span class="lineNum">    3599 </span><span class="lineNoCov">          0 :     delete Release(default_result_printer_);</span>
<span class="lineNum">    3600 </span><span class="lineNoCov">          0 :     default_result_printer_ = listener;</span>
<span class="lineNum">    3601 </span><span class="lineNoCov">          0 :     if (listener != NULL)</span>
<span class="lineNum">    3602 </span><span class="lineNoCov">          0 :       Append(listener);</span>
<span class="lineNum">    3603 </span>            :   }
<span class="lineNum">    3604 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3605 </span>            : 
<span class="lineNum">    3606 </span>            : // Sets the default_xml_generator attribute to the provided listener.  The
<span class="lineNum">    3607 </span>            : // listener is also added to the listener list and previous
<span class="lineNum">    3608 </span>            : // default_xml_generator is removed from it and deleted. The listener can
<a name="3609"><span class="lineNum">    3609 </span>            : // also be NULL in which case it will not be added to the list. Does</a>
<span class="lineNum">    3610 </span>            : // nothing if the previous and the current listener objects are the same.
<span class="lineNum">    3611 </span><span class="lineNoCov">          0 : void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {</span>
<span class="lineNum">    3612 </span><span class="lineNoCov">          0 :   if (default_xml_generator_ != listener) {</span>
<span class="lineNum">    3613 </span>            :     // It is an error to pass this method a listener that is already in the
<span class="lineNum">    3614 </span>            :     // list.
<span class="lineNum">    3615 </span><span class="lineNoCov">          0 :     delete Release(default_xml_generator_);</span>
<span class="lineNum">    3616 </span><span class="lineNoCov">          0 :     default_xml_generator_ = listener;</span>
<span class="lineNum">    3617 </span><span class="lineNoCov">          0 :     if (listener != NULL)</span>
<span class="lineNum">    3618 </span><span class="lineNoCov">          0 :       Append(listener);</span>
<span class="lineNum">    3619 </span>            :   }
<span class="lineNum">    3620 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3621 </span>            : 
<a name="3622"><span class="lineNum">    3622 </span>            : // Controls whether events will be forwarded by the repeater to the</a>
<span class="lineNum">    3623 </span>            : // listeners in the list.
<span class="lineNum">    3624 </span><span class="lineNoCov">          0 : bool TestEventListeners::EventForwardingEnabled() const {</span>
<span class="lineNum">    3625 </span><span class="lineNoCov">          0 :   return repeater_-&gt;forwarding_enabled();</span>
<a name="3626"><span class="lineNum">    3626 </span>            : }</a>
<span class="lineNum">    3627 </span>            : 
<span class="lineNum">    3628 </span><span class="lineNoCov">          0 : void TestEventListeners::SuppressEventForwarding() {</span>
<span class="lineNum">    3629 </span><span class="lineNoCov">          0 :   repeater_-&gt;set_forwarding_enabled(false);</span>
<span class="lineNum">    3630 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3631 </span>            : 
<span class="lineNum">    3632 </span>            : // class UnitTest
<span class="lineNum">    3633 </span>            : 
<span class="lineNum">    3634 </span>            : // Gets the singleton UnitTest object.  The first time this method is
<span class="lineNum">    3635 </span>            : // called, a UnitTest object is constructed and returned.  Consecutive
<span class="lineNum">    3636 </span>            : // calls will return the same object.
<span class="lineNum">    3637 </span>            : //
<span class="lineNum">    3638 </span>            : // We don't protect this under mutex_ as a user is not supposed to
<a name="3639"><span class="lineNum">    3639 </span>            : // call this before main() starts, from which point on the return</a>
<span class="lineNum">    3640 </span>            : // value will never change.
<span class="lineNum">    3641 </span><span class="lineNoCov">          0 : UnitTest* UnitTest::GetInstance() {</span>
<span class="lineNum">    3642 </span>            :   // When compiled with MSVC 7.1 in optimized mode, destroying the
<span class="lineNum">    3643 </span>            :   // UnitTest object upon exiting the program messes up the exit code,
<span class="lineNum">    3644 </span>            :   // causing successful tests to appear failed.  We have to use a
<span class="lineNum">    3645 </span>            :   // different implementation in this case to bypass the compiler bug.
<span class="lineNum">    3646 </span>            :   // This implementation makes the compiler happy, at the cost of
<span class="lineNum">    3647 </span>            :   // leaking the UnitTest object.
<span class="lineNum">    3648 </span>            : 
<span class="lineNum">    3649 </span>            :   // CodeGear C++Builder insists on a public destructor for the
<span class="lineNum">    3650 </span>            :   // default implementation.  Use this implementation to keep good OO
<span class="lineNum">    3651 </span>            :   // design with private destructor.
<span class="lineNum">    3652 </span>            : 
<span class="lineNum">    3653 </span>            : #if (_MSC_VER == 1310 &amp;&amp; !defined(_DEBUG)) || defined(__BORLANDC__)
<span class="lineNum">    3654 </span>            :   static UnitTest* const instance = new UnitTest;
<span class="lineNum">    3655 </span>            :   return instance;
<span class="lineNum">    3656 </span>            : #else
<span class="lineNum">    3657 </span><span class="lineNoCov">          0 :   static UnitTest instance;</span>
<span class="lineNum">    3658 </span><span class="lineNoCov">          0 :   return &amp;instance;</span>
<span class="lineNum">    3659 </span>            : #endif  // (_MSC_VER == 1310 &amp;&amp; !defined(_DEBUG)) || defined(__BORLANDC__)
<span class="lineNum">    3660 </span>            : }
<a name="3661"><span class="lineNum">    3661 </span>            : </a>
<span class="lineNum">    3662 </span>            : // Gets the number of successful test cases.
<span class="lineNum">    3663 </span><span class="lineNoCov">          0 : int UnitTest::successful_test_case_count() const {</span>
<span class="lineNum">    3664 </span><span class="lineNoCov">          0 :   return impl()-&gt;successful_test_case_count();</span>
<span class="lineNum">    3665 </span>            : }
<a name="3666"><span class="lineNum">    3666 </span>            : </a>
<span class="lineNum">    3667 </span>            : // Gets the number of failed test cases.
<span class="lineNum">    3668 </span><span class="lineNoCov">          0 : int UnitTest::failed_test_case_count() const {</span>
<span class="lineNum">    3669 </span><span class="lineNoCov">          0 :   return impl()-&gt;failed_test_case_count();</span>
<span class="lineNum">    3670 </span>            : }
<a name="3671"><span class="lineNum">    3671 </span>            : </a>
<span class="lineNum">    3672 </span>            : // Gets the number of all test cases.
<span class="lineNum">    3673 </span><span class="lineNoCov">          0 : int UnitTest::total_test_case_count() const {</span>
<span class="lineNum">    3674 </span><span class="lineNoCov">          0 :   return impl()-&gt;total_test_case_count();</span>
<span class="lineNum">    3675 </span>            : }
<span class="lineNum">    3676 </span>            : 
<a name="3677"><span class="lineNum">    3677 </span>            : // Gets the number of all test cases that contain at least one test</a>
<span class="lineNum">    3678 </span>            : // that should run.
<span class="lineNum">    3679 </span><span class="lineNoCov">          0 : int UnitTest::test_case_to_run_count() const {</span>
<span class="lineNum">    3680 </span><span class="lineNoCov">          0 :   return impl()-&gt;test_case_to_run_count();</span>
<span class="lineNum">    3681 </span>            : }
<a name="3682"><span class="lineNum">    3682 </span>            : </a>
<span class="lineNum">    3683 </span>            : // Gets the number of successful tests.
<span class="lineNum">    3684 </span><span class="lineNoCov">          0 : int UnitTest::successful_test_count() const {</span>
<span class="lineNum">    3685 </span><span class="lineNoCov">          0 :   return impl()-&gt;successful_test_count();</span>
<span class="lineNum">    3686 </span>            : }
<a name="3687"><span class="lineNum">    3687 </span>            : </a>
<span class="lineNum">    3688 </span>            : // Gets the number of failed tests.
<span class="lineNum">    3689 </span><span class="lineNoCov">          0 : int UnitTest::failed_test_count() const { return impl()-&gt;failed_test_count(); }</span>
<a name="3690"><span class="lineNum">    3690 </span>            : </a>
<span class="lineNum">    3691 </span>            : // Gets the number of disabled tests that will be reported in the XML report.
<span class="lineNum">    3692 </span><span class="lineNoCov">          0 : int UnitTest::reportable_disabled_test_count() const {</span>
<span class="lineNum">    3693 </span><span class="lineNoCov">          0 :   return impl()-&gt;reportable_disabled_test_count();</span>
<span class="lineNum">    3694 </span>            : }
<a name="3695"><span class="lineNum">    3695 </span>            : </a>
<span class="lineNum">    3696 </span>            : // Gets the number of disabled tests.
<span class="lineNum">    3697 </span><span class="lineNoCov">          0 : int UnitTest::disabled_test_count() const {</span>
<span class="lineNum">    3698 </span><span class="lineNoCov">          0 :   return impl()-&gt;disabled_test_count();</span>
<span class="lineNum">    3699 </span>            : }
<a name="3700"><span class="lineNum">    3700 </span>            : </a>
<span class="lineNum">    3701 </span>            : // Gets the number of tests to be printed in the XML report.
<span class="lineNum">    3702 </span><span class="lineNoCov">          0 : int UnitTest::reportable_test_count() const {</span>
<span class="lineNum">    3703 </span><span class="lineNoCov">          0 :   return impl()-&gt;reportable_test_count();</span>
<span class="lineNum">    3704 </span>            : }
<a name="3705"><span class="lineNum">    3705 </span>            : </a>
<span class="lineNum">    3706 </span>            : // Gets the number of all tests.
<span class="lineNum">    3707 </span><span class="lineNoCov">          0 : int UnitTest::total_test_count() const { return impl()-&gt;total_test_count(); }</span>
<a name="3708"><span class="lineNum">    3708 </span>            : </a>
<span class="lineNum">    3709 </span>            : // Gets the number of tests that should run.
<span class="lineNum">    3710 </span><span class="lineNoCov">          0 : int UnitTest::test_to_run_count() const { return impl()-&gt;test_to_run_count(); }</span>
<span class="lineNum">    3711 </span>            : 
<a name="3712"><span class="lineNum">    3712 </span>            : // Gets the time of the test program start, in ms from the start of the</a>
<span class="lineNum">    3713 </span>            : // UNIX epoch.
<span class="lineNum">    3714 </span><span class="lineNoCov">          0 : internal::TimeInMillis UnitTest::start_timestamp() const {</span>
<span class="lineNum">    3715 </span><span class="lineNoCov">          0 :     return impl()-&gt;start_timestamp();</span>
<span class="lineNum">    3716 </span>            : }
<a name="3717"><span class="lineNum">    3717 </span>            : </a>
<span class="lineNum">    3718 </span>            : // Gets the elapsed time, in milliseconds.
<span class="lineNum">    3719 </span><span class="lineNoCov">          0 : internal::TimeInMillis UnitTest::elapsed_time() const {</span>
<span class="lineNum">    3720 </span><span class="lineNoCov">          0 :   return impl()-&gt;elapsed_time();</span>
<span class="lineNum">    3721 </span>            : }
<a name="3722"><span class="lineNum">    3722 </span>            : </a>
<span class="lineNum">    3723 </span>            : // Returns true iff the unit test passed (i.e. all test cases passed).
<span class="lineNum">    3724 </span><span class="lineNoCov">          0 : bool UnitTest::Passed() const { return impl()-&gt;Passed(); }</span>
<span class="lineNum">    3725 </span>            : 
<a name="3726"><span class="lineNum">    3726 </span>            : // Returns true iff the unit test failed (i.e. some test case failed</a>
<span class="lineNum">    3727 </span>            : // or something outside of all tests failed).
<span class="lineNum">    3728 </span><span class="lineNoCov">          0 : bool UnitTest::Failed() const { return impl()-&gt;Failed(); }</span>
<span class="lineNum">    3729 </span>            : 
<a name="3730"><span class="lineNum">    3730 </span>            : // Gets the i-th test case among all the test cases. i can range from 0 to</a>
<span class="lineNum">    3731 </span>            : // total_test_case_count() - 1. If i is not in that range, returns NULL.
<span class="lineNum">    3732 </span><span class="lineNoCov">          0 : const TestCase* UnitTest::GetTestCase(int i) const {</span>
<span class="lineNum">    3733 </span><span class="lineNoCov">          0 :   return impl()-&gt;GetTestCase(i);</span>
<span class="lineNum">    3734 </span>            : }
<span class="lineNum">    3735 </span>            : 
<a name="3736"><span class="lineNum">    3736 </span>            : // Returns the TestResult containing information on test failures and</a>
<span class="lineNum">    3737 </span>            : // properties logged outside of individual test cases.
<span class="lineNum">    3738 </span><span class="lineNoCov">          0 : const TestResult&amp; UnitTest::ad_hoc_test_result() const {</span>
<span class="lineNum">    3739 </span><span class="lineNoCov">          0 :   return *impl()-&gt;ad_hoc_test_result();</span>
<span class="lineNum">    3740 </span>            : }
<span class="lineNum">    3741 </span>            : 
<a name="3742"><span class="lineNum">    3742 </span>            : // Gets the i-th test case among all the test cases. i can range from 0 to</a>
<span class="lineNum">    3743 </span>            : // total_test_case_count() - 1. If i is not in that range, returns NULL.
<span class="lineNum">    3744 </span><span class="lineNoCov">          0 : TestCase* UnitTest::GetMutableTestCase(int i) {</span>
<span class="lineNum">    3745 </span><span class="lineNoCov">          0 :   return impl()-&gt;GetMutableTestCase(i);</span>
<span class="lineNum">    3746 </span>            : }
<span class="lineNum">    3747 </span>            : 
<a name="3748"><span class="lineNum">    3748 </span>            : // Returns the list of event listeners that can be used to track events</a>
<span class="lineNum">    3749 </span>            : // inside Google Test.
<span class="lineNum">    3750 </span><span class="lineNoCov">          0 : TestEventListeners&amp; UnitTest::listeners() {</span>
<span class="lineNum">    3751 </span><span class="lineNoCov">          0 :   return *impl()-&gt;listeners();</span>
<span class="lineNum">    3752 </span>            : }
<span class="lineNum">    3753 </span>            : 
<span class="lineNum">    3754 </span>            : // Registers and returns a global test environment.  When a test
<span class="lineNum">    3755 </span>            : // program is run, all global test environments will be set-up in the
<span class="lineNum">    3756 </span>            : // order they were registered.  After all tests in the program have
<span class="lineNum">    3757 </span>            : // finished, all global test environments will be torn-down in the
<span class="lineNum">    3758 </span>            : // *reverse* order they were registered.
<span class="lineNum">    3759 </span>            : //
<span class="lineNum">    3760 </span>            : // The UnitTest object takes ownership of the given environment.
<span class="lineNum">    3761 </span>            : //
<a name="3762"><span class="lineNum">    3762 </span>            : // We don't protect this under mutex_, as we only support calling it</a>
<span class="lineNum">    3763 </span>            : // from the main thread.
<span class="lineNum">    3764 </span><span class="lineNoCov">          0 : Environment* UnitTest::AddEnvironment(Environment* env) {</span>
<span class="lineNum">    3765 </span><span class="lineNoCov">          0 :   if (env == NULL) {</span>
<span class="lineNum">    3766 </span><span class="lineNoCov">          0 :     return NULL;</span>
<span class="lineNum">    3767 </span>            :   }
<span class="lineNum">    3768 </span>            : 
<span class="lineNum">    3769 </span><span class="lineNoCov">          0 :   impl_-&gt;environments().push_back(env);</span>
<span class="lineNum">    3770 </span><span class="lineNoCov">          0 :   return env;</span>
<span class="lineNum">    3771 </span>            : }
<span class="lineNum">    3772 </span>            : 
<span class="lineNum">    3773 </span>            : // Adds a TestPartResult to the current TestResult object.  All Google Test
<span class="lineNum">    3774 </span>            : // assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
<a name="3775"><span class="lineNum">    3775 </span>            : // this to report their results.  The user code should use the</a>
<span class="lineNum">    3776 </span>            : // assertion macros instead of calling this directly.
<span class="lineNum">    3777 </span><span class="lineNoCov">          0 : void UnitTest::AddTestPartResult(</span>
<span class="lineNum">    3778 </span>            :     TestPartResult::Type result_type,
<span class="lineNum">    3779 </span>            :     const char* file_name,
<span class="lineNum">    3780 </span>            :     int line_number,
<span class="lineNum">    3781 </span>            :     const std::string&amp; message,
<span class="lineNum">    3782 </span>            :     const std::string&amp; os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3783 </span><span class="lineNoCov">          0 :   Message msg;</span>
<span class="lineNum">    3784 </span><span class="lineNoCov">          0 :   msg &lt;&lt; message;</span>
<span class="lineNum">    3785 </span>            : 
<span class="lineNum">    3786 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;mutex_);</span>
<span class="lineNum">    3787 </span><span class="lineNoCov">          0 :   if (impl_-&gt;gtest_trace_stack().size() &gt; 0) {</span>
<span class="lineNum">    3788 </span><span class="lineNoCov">          0 :     msg &lt;&lt; &quot;\n&quot; &lt;&lt; GTEST_NAME_ &lt;&lt; &quot; trace:&quot;;</span>
<span class="lineNum">    3789 </span>            : 
<span class="lineNum">    3790 </span><span class="lineNoCov">          0 :     for (int i = static_cast&lt;int&gt;(impl_-&gt;gtest_trace_stack().size());</span>
<span class="lineNum">    3791 </span><span class="lineNoCov">          0 :          i &gt; 0; --i) {</span>
<span class="lineNum">    3792 </span><span class="lineNoCov">          0 :       const internal::TraceInfo&amp; trace = impl_-&gt;gtest_trace_stack()[i - 1];</span>
<span class="lineNum">    3793 </span><span class="lineNoCov">          0 :       msg &lt;&lt; &quot;\n&quot; &lt;&lt; internal::FormatFileLocation(trace.file, trace.line)</span>
<span class="lineNum">    3794 </span><span class="lineNoCov">          0 :           &lt;&lt; &quot; &quot; &lt;&lt; trace.message;</span>
<span class="lineNum">    3795 </span>            :     }
<span class="lineNum">    3796 </span>            :   }
<span class="lineNum">    3797 </span>            : 
<span class="lineNum">    3798 </span><span class="lineNoCov">          0 :   if (os_stack_trace.c_str() != NULL &amp;&amp; !os_stack_trace.empty()) {</span>
<span class="lineNum">    3799 </span><span class="lineNoCov">          0 :     msg &lt;&lt; internal::kStackTraceMarker &lt;&lt; os_stack_trace;</span>
<span class="lineNum">    3800 </span>            :   }
<span class="lineNum">    3801 </span>            : 
<span class="lineNum">    3802 </span>            :   const TestPartResult result =
<span class="lineNum">    3803 </span>            :     TestPartResult(result_type, file_name, line_number,
<span class="lineNum">    3804 </span><span class="lineNoCov">          0 :                    msg.GetString().c_str());</span>
<span class="lineNum">    3805 </span><span class="lineNoCov">          0 :   impl_-&gt;GetTestPartResultReporterForCurrentThread()-&gt;</span>
<span class="lineNum">    3806 </span><span class="lineNoCov">          0 :       ReportTestPartResult(result);</span>
<span class="lineNum">    3807 </span>            : 
<span class="lineNum">    3808 </span><span class="lineNoCov">          0 :   if (result_type != TestPartResult::kSuccess) {</span>
<span class="lineNum">    3809 </span>            :     // gtest_break_on_failure takes precedence over
<span class="lineNum">    3810 </span>            :     // gtest_throw_on_failure.  This allows a user to set the latter
<span class="lineNum">    3811 </span>            :     // in the code (perhaps in order to use Google Test assertions
<span class="lineNum">    3812 </span>            :     // with another testing framework) and specify the former on the
<span class="lineNum">    3813 </span>            :     // command line for debugging.
<span class="lineNum">    3814 </span><span class="lineNoCov">          0 :     if (GTEST_FLAG(break_on_failure)) {</span>
<span class="lineNum">    3815 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    3816 </span>            :       // Using DebugBreak on Windows allows gtest to still break into a debugger
<span class="lineNum">    3817 </span>            :       // when a failure happens and both the --gtest_break_on_failure and
<span class="lineNum">    3818 </span>            :       // the --gtest_catch_exceptions flags are specified.
<span class="lineNum">    3819 </span>            :       DebugBreak();
<span class="lineNum">    3820 </span>            : #else
<span class="lineNum">    3821 </span>            :       // Dereference NULL through a volatile pointer to prevent the compiler
<span class="lineNum">    3822 </span>            :       // from removing. We use this rather than abort() or __builtin_trap() for
<span class="lineNum">    3823 </span>            :       // portability: Symbian doesn't implement abort() well, and some debuggers
<span class="lineNum">    3824 </span>            :       // don't correctly trap abort().
<span class="lineNum">    3825 </span><span class="lineNoCov">          0 :       *static_cast&lt;volatile int*&gt;(NULL) = 1;</span>
<span class="lineNum">    3826 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    3827 </span><span class="lineNoCov">          0 :     } else if (GTEST_FLAG(throw_on_failure)) {</span>
<span class="lineNum">    3828 </span>            : #if GTEST_HAS_EXCEPTIONS
<span class="lineNum">    3829 </span><span class="lineNoCov">          0 :       throw internal::GoogleTestFailureException(result);</span>
<span class="lineNum">    3830 </span>            : #else
<span class="lineNum">    3831 </span>            :       // We cannot call abort() as it generates a pop-up in debug mode
<span class="lineNum">    3832 </span>            :       // that cannot be suppressed in VC 7.1 or below.
<span class="lineNum">    3833 </span>            :       exit(1);
<span class="lineNum">    3834 </span>            : #endif
<span class="lineNum">    3835 </span>            :     }
<span class="lineNum">    3836 </span>            :   }
<span class="lineNum">    3837 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3838 </span>            : 
<span class="lineNum">    3839 </span>            : // Adds a TestProperty to the current TestResult object when invoked from
<span class="lineNum">    3840 </span>            : // inside a test, to current TestCase's ad_hoc_test_result_ when invoked
<span class="lineNum">    3841 </span>            : // from SetUpTestCase or TearDownTestCase, or to the global property set
<a name="3842"><span class="lineNum">    3842 </span>            : // when invoked elsewhere.  If the result already contains a property with</a>
<span class="lineNum">    3843 </span>            : // the same key, the value will be updated.
<span class="lineNum">    3844 </span><span class="lineNoCov">          0 : void UnitTest::RecordProperty(const std::string&amp; key,</span>
<span class="lineNum">    3845 </span>            :                               const std::string&amp; value) {
<span class="lineNum">    3846 </span><span class="lineNoCov">          0 :   impl_-&gt;RecordProperty(TestProperty(key, value));</span>
<span class="lineNum">    3847 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3848 </span>            : 
<span class="lineNum">    3849 </span>            : // Runs all tests in this UnitTest object and prints the result.
<span class="lineNum">    3850 </span>            : // Returns 0 if successful, or 1 otherwise.
<span class="lineNum">    3851 </span>            : //
<a name="3852"><span class="lineNum">    3852 </span>            : // We don't protect this under mutex_, as we only support calling it</a>
<span class="lineNum">    3853 </span>            : // from the main thread.
<span class="lineNum">    3854 </span><span class="lineNoCov">          0 : int UnitTest::Run() {</span>
<span class="lineNum">    3855 </span>            :   const bool in_death_test_child_process =
<span class="lineNum">    3856 </span><span class="lineNoCov">          0 :       internal::GTEST_FLAG(internal_run_death_test).length() &gt; 0;</span>
<span class="lineNum">    3857 </span>            : 
<span class="lineNum">    3858 </span>            :   // Google Test implements this protocol for catching that a test
<span class="lineNum">    3859 </span>            :   // program exits before returning control to Google Test:
<span class="lineNum">    3860 </span>            :   //
<span class="lineNum">    3861 </span>            :   //   1. Upon start, Google Test creates a file whose absolute path
<span class="lineNum">    3862 </span>            :   //      is specified by the environment variable
<span class="lineNum">    3863 </span>            :   //      TEST_PREMATURE_EXIT_FILE.
<span class="lineNum">    3864 </span>            :   //   2. When Google Test has finished its work, it deletes the file.
<span class="lineNum">    3865 </span>            :   //
<span class="lineNum">    3866 </span>            :   // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
<span class="lineNum">    3867 </span>            :   // running a Google-Test-based test program and check the existence
<span class="lineNum">    3868 </span>            :   // of the file at the end of the test execution to see if it has
<span class="lineNum">    3869 </span>            :   // exited prematurely.
<span class="lineNum">    3870 </span>            : 
<span class="lineNum">    3871 </span>            :   // If we are in the child process of a death test, don't
<span class="lineNum">    3872 </span>            :   // create/delete the premature exit file, as doing so is unnecessary
<span class="lineNum">    3873 </span>            :   // and will confuse the parent process.  Otherwise, create/delete
<span class="lineNum">    3874 </span>            :   // the file upon entering/leaving this function.  If the program
<span class="lineNum">    3875 </span>            :   // somehow exits before this function has a chance to return, the
<span class="lineNum">    3876 </span>            :   // premature-exit file will be left undeleted, causing a test runner
<span class="lineNum">    3877 </span>            :   // that understands the premature-exit-file protocol to report the
<span class="lineNum">    3878 </span>            :   // test as having failed.
<span class="lineNum">    3879 </span>            :   const internal::ScopedPrematureExitFile premature_exit_file(
<span class="lineNum">    3880 </span>            :       in_death_test_child_process ?
<span class="lineNum">    3881 </span><span class="lineNoCov">          0 :       NULL : internal::posix::GetEnv(&quot;TEST_PREMATURE_EXIT_FILE&quot;));</span>
<span class="lineNum">    3882 </span>            : 
<span class="lineNum">    3883 </span>            :   // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be
<span class="lineNum">    3884 </span>            :   // used for the duration of the program.
<span class="lineNum">    3885 </span><span class="lineNoCov">          0 :   impl()-&gt;set_catch_exceptions(GTEST_FLAG(catch_exceptions));</span>
<span class="lineNum">    3886 </span>            : 
<span class="lineNum">    3887 </span>            : #if GTEST_HAS_SEH
<span class="lineNum">    3888 </span>            :   // Either the user wants Google Test to catch exceptions thrown by the
<span class="lineNum">    3889 </span>            :   // tests or this is executing in the context of death test child
<span class="lineNum">    3890 </span>            :   // process. In either case the user does not want to see pop-up dialogs
<span class="lineNum">    3891 </span>            :   // about crashes - they are expected.
<span class="lineNum">    3892 </span>            :   if (impl()-&gt;catch_exceptions() || in_death_test_child_process) {
<span class="lineNum">    3893 </span>            : # if !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    3894 </span>            :     // SetErrorMode doesn't exist on CE.
<span class="lineNum">    3895 </span>            :     SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
<span class="lineNum">    3896 </span>            :                  SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
<span class="lineNum">    3897 </span>            : # endif  // !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    3898 </span>            : 
<span class="lineNum">    3899 </span>            : # if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    3900 </span>            :     // Death test children can be terminated with _abort().  On Windows,
<span class="lineNum">    3901 </span>            :     // _abort() can show a dialog with a warning message.  This forces the
<span class="lineNum">    3902 </span>            :     // abort message to go to stderr instead.
<span class="lineNum">    3903 </span>            :     _set_error_mode(_OUT_TO_STDERR);
<span class="lineNum">    3904 </span>            : # endif
<span class="lineNum">    3905 </span>            : 
<span class="lineNum">    3906 </span>            : # if _MSC_VER &gt;= 1400 &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    3907 </span>            :     // In the debug version, Visual Studio pops up a separate dialog
<span class="lineNum">    3908 </span>            :     // offering a choice to debug the aborted program. We need to suppress
<span class="lineNum">    3909 </span>            :     // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
<span class="lineNum">    3910 </span>            :     // executed. Google Test will notify the user of any unexpected
<span class="lineNum">    3911 </span>            :     // failure via stderr.
<span class="lineNum">    3912 </span>            :     //
<span class="lineNum">    3913 </span>            :     // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
<span class="lineNum">    3914 </span>            :     // Users of prior VC versions shall suffer the agony and pain of
<span class="lineNum">    3915 </span>            :     // clicking through the countless debug dialogs.
<span class="lineNum">    3916 </span>            :     // TODO(vladl@google.com): find a way to suppress the abort dialog() in the
<span class="lineNum">    3917 </span>            :     // debug mode when compiled with VC 7.1 or lower.
<span class="lineNum">    3918 </span>            :     if (!GTEST_FLAG(break_on_failure))
<span class="lineNum">    3919 </span>            :       _set_abort_behavior(
<span class="lineNum">    3920 </span>            :           0x0,                                    // Clear the following flags:
<span class="lineNum">    3921 </span>            :           _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.
<span class="lineNum">    3922 </span>            : # endif
<span class="lineNum">    3923 </span>            :   }
<span class="lineNum">    3924 </span>            : #endif  // GTEST_HAS_SEH
<span class="lineNum">    3925 </span>            : 
<span class="lineNum">    3926 </span><span class="lineNoCov">          0 :   return internal::HandleExceptionsInMethodIfSupported(</span>
<span class="lineNum">    3927 </span>            :       impl(),
<span class="lineNum">    3928 </span>            :       &amp;internal::UnitTestImpl::RunAllTests,
<span class="lineNum">    3929 </span><span class="lineNoCov">          0 :       &quot;auxiliary test code (environments or event listeners)&quot;) ? 0 : 1;</span>
<span class="lineNum">    3930 </span>            : }
<span class="lineNum">    3931 </span>            : 
<a name="3932"><span class="lineNum">    3932 </span>            : // Returns the working directory when the first TEST() or TEST_F() was</a>
<span class="lineNum">    3933 </span>            : // executed.
<span class="lineNum">    3934 </span><span class="lineNoCov">          0 : const char* UnitTest::original_working_dir() const {</span>
<span class="lineNum">    3935 </span><span class="lineNoCov">          0 :   return impl_-&gt;original_working_dir_.c_str();</span>
<span class="lineNum">    3936 </span>            : }
<span class="lineNum">    3937 </span>            : 
<a name="3938"><span class="lineNum">    3938 </span>            : // Returns the TestCase object for the test that's currently running,</a>
<span class="lineNum">    3939 </span>            : // or NULL if no test is running.
<span class="lineNum">    3940 </span><span class="lineNoCov">          0 : const TestCase* UnitTest::current_test_case() const</span>
<span class="lineNum">    3941 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3942 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;mutex_);</span>
<span class="lineNum">    3943 </span><span class="lineNoCov">          0 :   return impl_-&gt;current_test_case();</span>
<span class="lineNum">    3944 </span>            : }
<span class="lineNum">    3945 </span>            : 
<a name="3946"><span class="lineNum">    3946 </span>            : // Returns the TestInfo object for the test that's currently running,</a>
<span class="lineNum">    3947 </span>            : // or NULL if no test is running.
<span class="lineNum">    3948 </span><span class="lineNoCov">          0 : const TestInfo* UnitTest::current_test_info() const</span>
<span class="lineNum">    3949 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3950 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;mutex_);</span>
<span class="lineNum">    3951 </span><span class="lineNoCov">          0 :   return impl_-&gt;current_test_info();</span>
<span class="lineNum">    3952 </span>            : }
<a name="3953"><span class="lineNum">    3953 </span>            : </a>
<span class="lineNum">    3954 </span>            : // Returns the random seed used at the start of the current test run.
<span class="lineNum">    3955 </span><span class="lineNoCov">          0 : int UnitTest::random_seed() const { return impl_-&gt;random_seed(); }</span>
<span class="lineNum">    3956 </span>            : 
<span class="lineNum">    3957 </span>            : #if GTEST_HAS_PARAM_TEST
<span class="lineNum">    3958 </span>            : // Returns ParameterizedTestCaseRegistry object used to keep track of
<a name="3959"><span class="lineNum">    3959 </span>            : // value-parameterized tests and instantiate and register them.</a>
<span class="lineNum">    3960 </span>            : internal::ParameterizedTestCaseRegistry&amp;
<span class="lineNum">    3961 </span><span class="lineNoCov">          0 :     UnitTest::parameterized_test_registry()</span>
<span class="lineNum">    3962 </span>            :         GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3963 </span><span class="lineNoCov">          0 :   return impl_-&gt;parameterized_test_registry();</span>
<span class="lineNum">    3964 </span>            : }
<span class="lineNum">    3965 </span>            : #endif  // GTEST_HAS_PARAM_TEST
<a name="3966"><span class="lineNum">    3966 </span>            : </a>
<span class="lineNum">    3967 </span>            : // Creates an empty UnitTest.
<span class="lineNum">    3968 </span><span class="lineNoCov">          0 : UnitTest::UnitTest() {</span>
<span class="lineNum">    3969 </span><span class="lineNoCov">          0 :   impl_ = new internal::UnitTestImpl(this);</span>
<span class="lineNum">    3970 </span><span class="lineNoCov">          0 : }</span>
<a name="3971"><span class="lineNum">    3971 </span>            : </a>
<span class="lineNum">    3972 </span>            : // Destructor of UnitTest.
<span class="lineNum">    3973 </span><span class="lineNoCov">          0 : UnitTest::~UnitTest() {</span>
<span class="lineNum">    3974 </span><span class="lineNoCov">          0 :   delete impl_;</span>
<span class="lineNum">    3975 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3976 </span>            : 
<a name="3977"><span class="lineNum">    3977 </span>            : // Pushes a trace defined by SCOPED_TRACE() on to the per-thread</a>
<span class="lineNum">    3978 </span>            : // Google Test trace stack.
<span class="lineNum">    3979 </span><span class="lineNoCov">          0 : void UnitTest::PushGTestTrace(const internal::TraceInfo&amp; trace)</span>
<span class="lineNum">    3980 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3981 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;mutex_);</span>
<span class="lineNum">    3982 </span><span class="lineNoCov">          0 :   impl_-&gt;gtest_trace_stack().push_back(trace);</span>
<span class="lineNum">    3983 </span><span class="lineNoCov">          0 : }</span>
<a name="3984"><span class="lineNum">    3984 </span>            : </a>
<span class="lineNum">    3985 </span>            : // Pops a trace from the per-thread Google Test trace stack.
<span class="lineNum">    3986 </span><span class="lineNoCov">          0 : void UnitTest::PopGTestTrace()</span>
<span class="lineNum">    3987 </span>            :     GTEST_LOCK_EXCLUDED_(mutex_) {
<span class="lineNum">    3988 </span><span class="lineNoCov">          0 :   internal::MutexLock lock(&amp;mutex_);</span>
<span class="lineNum">    3989 </span><span class="lineNoCov">          0 :   impl_-&gt;gtest_trace_stack().pop_back();</span>
<span class="lineNum">    3990 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    3991 </span>            : 
<a name="3992"><span class="lineNum">    3992 </span>            : namespace internal {</a>
<span class="lineNum">    3993 </span>            : 
<span class="lineNum">    3994 </span><span class="lineNoCov">          0 : UnitTestImpl::UnitTestImpl(UnitTest* parent)</span>
<span class="lineNum">    3995 </span>            :     : parent_(parent),
<span class="lineNum">    3996 </span>            : #ifdef _MSC_VER
<span class="lineNum">    3997 </span>            : # pragma warning(push)                    // Saves the current warning state.
<span class="lineNum">    3998 </span>            : # pragma warning(disable:4355)            // Temporarily disables warning 4355
<span class="lineNum">    3999 </span>            :                                          // (using this in initializer).
<span class="lineNum">    4000 </span>            :       default_global_test_part_result_reporter_(this),
<span class="lineNum">    4001 </span>            :       default_per_thread_test_part_result_reporter_(this),
<span class="lineNum">    4002 </span>            : # pragma warning(pop)                     // Restores the warning state again.
<span class="lineNum">    4003 </span>            : #else
<span class="lineNum">    4004 </span>            :       default_global_test_part_result_reporter_(this),
<span class="lineNum">    4005 </span>            :       default_per_thread_test_part_result_reporter_(this),
<span class="lineNum">    4006 </span>            : #endif  // _MSC_VER
<span class="lineNum">    4007 </span>            :       global_test_part_result_repoter_(
<span class="lineNum">    4008 </span>            :           &amp;default_global_test_part_result_reporter_),
<span class="lineNum">    4009 </span>            :       per_thread_test_part_result_reporter_(
<span class="lineNum">    4010 </span>            :           &amp;default_per_thread_test_part_result_reporter_),
<span class="lineNum">    4011 </span>            : #if GTEST_HAS_PARAM_TEST
<span class="lineNum">    4012 </span>            :       parameterized_test_registry_(),
<span class="lineNum">    4013 </span>            :       parameterized_tests_registered_(false),
<span class="lineNum">    4014 </span>            : #endif  // GTEST_HAS_PARAM_TEST
<span class="lineNum">    4015 </span>            :       last_death_test_case_(-1),
<span class="lineNum">    4016 </span>            :       current_test_case_(NULL),
<span class="lineNum">    4017 </span>            :       current_test_info_(NULL),
<span class="lineNum">    4018 </span>            :       ad_hoc_test_result_(),
<span class="lineNum">    4019 </span>            :       os_stack_trace_getter_(NULL),
<span class="lineNum">    4020 </span>            :       post_flag_parse_init_performed_(false),
<span class="lineNum">    4021 </span>            :       random_seed_(0),  // Will be overridden by the flag before first use.
<span class="lineNum">    4022 </span>            :       random_(0),  // Will be reseeded before first use.
<span class="lineNum">    4023 </span>            :       start_timestamp_(0),
<span class="lineNum">    4024 </span>            :       elapsed_time_(0),
<span class="lineNum">    4025 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">    4026 </span><span class="lineNoCov">          0 :       death_test_factory_(new DefaultDeathTestFactory),</span>
<span class="lineNum">    4027 </span>            : #endif
<span class="lineNum">    4028 </span>            :       // Will be overridden by the flag before first use.
<span class="lineNum">    4029 </span><span class="lineNoCov">          0 :       catch_exceptions_(false) {</span>
<span class="lineNum">    4030 </span><span class="lineNoCov">          0 :   listeners()-&gt;SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);</span>
<a name="4031"><span class="lineNum">    4031 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">    4032 </span>            : 
<span class="lineNum">    4033 </span><span class="lineNoCov">          0 : UnitTestImpl::~UnitTestImpl() {</span>
<span class="lineNum">    4034 </span>            :   // Deletes every TestCase.
<span class="lineNum">    4035 </span><span class="lineNoCov">          0 :   ForEach(test_cases_, internal::Delete&lt;TestCase&gt;);</span>
<span class="lineNum">    4036 </span>            : 
<span class="lineNum">    4037 </span>            :   // Deletes every Environment.
<span class="lineNum">    4038 </span><span class="lineNoCov">          0 :   ForEach(environments_, internal::Delete&lt;Environment&gt;);</span>
<span class="lineNum">    4039 </span>            : 
<span class="lineNum">    4040 </span><span class="lineNoCov">          0 :   delete os_stack_trace_getter_;</span>
<span class="lineNum">    4041 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4042 </span>            : 
<span class="lineNum">    4043 </span>            : // Adds a TestProperty to the current TestResult object when invoked in a
<span class="lineNum">    4044 </span>            : // context of a test, to current test case's ad_hoc_test_result when invoke
<span class="lineNum">    4045 </span>            : // from SetUpTestCase/TearDownTestCase, or to the global property set
<a name="4046"><span class="lineNum">    4046 </span>            : // otherwise.  If the result already contains a property with the same key,</a>
<span class="lineNum">    4047 </span>            : // the value will be updated.
<span class="lineNum">    4048 </span><span class="lineNoCov">          0 : void UnitTestImpl::RecordProperty(const TestProperty&amp; test_property) {</span>
<span class="lineNum">    4049 </span><span class="lineNoCov">          0 :   std::string xml_element;</span>
<span class="lineNum">    4050 </span>            :   TestResult* test_result;  // TestResult appropriate for property recording.
<span class="lineNum">    4051 </span>            : 
<span class="lineNum">    4052 </span><span class="lineNoCov">          0 :   if (current_test_info_ != NULL) {</span>
<span class="lineNum">    4053 </span><span class="lineNoCov">          0 :     xml_element = &quot;testcase&quot;;</span>
<span class="lineNum">    4054 </span><span class="lineNoCov">          0 :     test_result = &amp;(current_test_info_-&gt;result_);</span>
<span class="lineNum">    4055 </span><span class="lineNoCov">          0 :   } else if (current_test_case_ != NULL) {</span>
<span class="lineNum">    4056 </span><span class="lineNoCov">          0 :     xml_element = &quot;testsuite&quot;;</span>
<span class="lineNum">    4057 </span><span class="lineNoCov">          0 :     test_result = &amp;(current_test_case_-&gt;ad_hoc_test_result_);</span>
<span class="lineNum">    4058 </span>            :   } else {
<span class="lineNum">    4059 </span><span class="lineNoCov">          0 :     xml_element = &quot;testsuites&quot;;</span>
<span class="lineNum">    4060 </span><span class="lineNoCov">          0 :     test_result = &amp;ad_hoc_test_result_;</span>
<span class="lineNum">    4061 </span>            :   }
<span class="lineNum">    4062 </span><span class="lineNoCov">          0 :   test_result-&gt;RecordProperty(xml_element, test_property);</span>
<span class="lineNum">    4063 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4064 </span>            : 
<span class="lineNum">    4065 </span>            : #if GTEST_HAS_DEATH_TEST
<a name="4066"><span class="lineNum">    4066 </span>            : // Disables event forwarding if the control is currently in a death test</a>
<span class="lineNum">    4067 </span>            : // subprocess. Must not be called before InitGoogleTest.
<span class="lineNum">    4068 </span><span class="lineNoCov">          0 : void UnitTestImpl::SuppressTestEventsIfInSubprocess() {</span>
<span class="lineNum">    4069 </span><span class="lineNoCov">          0 :   if (internal_run_death_test_flag_.get() != NULL)</span>
<span class="lineNum">    4070 </span><span class="lineNoCov">          0 :     listeners()-&gt;SuppressEventForwarding();</span>
<span class="lineNum">    4071 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4072 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">    4073 </span>            : 
<a name="4074"><span class="lineNum">    4074 </span>            : // Initializes event listeners performing XML output as specified by</a>
<span class="lineNum">    4075 </span>            : // UnitTestOptions. Must not be called before InitGoogleTest.
<span class="lineNum">    4076 </span><span class="lineNoCov">          0 : void UnitTestImpl::ConfigureXmlOutput() {</span>
<span class="lineNum">    4077 </span><span class="lineNoCov">          0 :   const std::string&amp; output_format = UnitTestOptions::GetOutputFormat();</span>
<span class="lineNum">    4078 </span><span class="lineNoCov">          0 :   if (output_format == &quot;xml&quot;) {</span>
<span class="lineNum">    4079 </span><span class="lineNoCov">          0 :     listeners()-&gt;SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(</span>
<span class="lineNum">    4080 </span><span class="lineNoCov">          0 :         UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));</span>
<span class="lineNum">    4081 </span><span class="lineNoCov">          0 :   } else if (output_format != &quot;&quot;) {</span>
<span class="lineNum">    4082 </span><span class="lineNoCov">          0 :     printf(&quot;WARNING: unrecognized output format \&quot;%s\&quot; ignored.\n&quot;,</span>
<span class="lineNum">    4083 </span><span class="lineNoCov">          0 :            output_format.c_str());</span>
<span class="lineNum">    4084 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">    4085 </span>            :   }
<span class="lineNum">    4086 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4087 </span>            : 
<span class="lineNum">    4088 </span>            : #if GTEST_CAN_STREAM_RESULTS_
<a name="4089"><span class="lineNum">    4089 </span>            : // Initializes event listeners for streaming test results in string form.</a>
<span class="lineNum">    4090 </span>            : // Must not be called before InitGoogleTest.
<span class="lineNum">    4091 </span><span class="lineNoCov">          0 : void UnitTestImpl::ConfigureStreamingOutput() {</span>
<span class="lineNum">    4092 </span><span class="lineNoCov">          0 :   const std::string&amp; target = GTEST_FLAG(stream_result_to);</span>
<span class="lineNum">    4093 </span><span class="lineNoCov">          0 :   if (!target.empty()) {</span>
<span class="lineNum">    4094 </span><span class="lineNoCov">          0 :     const size_t pos = target.find(':');</span>
<span class="lineNum">    4095 </span><span class="lineNoCov">          0 :     if (pos != std::string::npos) {</span>
<span class="lineNum">    4096 </span><span class="lineNoCov">          0 :       listeners()-&gt;Append(new StreamingListener(target.substr(0, pos),</span>
<span class="lineNum">    4097 </span><span class="lineNoCov">          0 :                                                 target.substr(pos+1)));</span>
<span class="lineNum">    4098 </span>            :     } else {
<span class="lineNum">    4099 </span><span class="lineNoCov">          0 :       printf(&quot;WARNING: unrecognized streaming target \&quot;%s\&quot; ignored.\n&quot;,</span>
<span class="lineNum">    4100 </span><span class="lineNoCov">          0 :              target.c_str());</span>
<span class="lineNum">    4101 </span><span class="lineNoCov">          0 :       fflush(stdout);</span>
<span class="lineNum">    4102 </span>            :     }
<span class="lineNum">    4103 </span>            :   }
<span class="lineNum">    4104 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4105 </span>            : #endif  // GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    4106 </span>            : 
<span class="lineNum">    4107 </span>            : // Performs initialization dependent upon flag values obtained in
<span class="lineNum">    4108 </span>            : // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
<span class="lineNum">    4109 </span>            : // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
<a name="4110"><span class="lineNum">    4110 </span>            : // this function is also called from RunAllTests.  Since this function can be</a>
<span class="lineNum">    4111 </span>            : // called more than once, it has to be idempotent.
<span class="lineNum">    4112 </span><span class="lineNoCov">          0 : void UnitTestImpl::PostFlagParsingInit() {</span>
<span class="lineNum">    4113 </span>            :   // Ensures that this function does not execute more than once.
<span class="lineNum">    4114 </span><span class="lineNoCov">          0 :   if (!post_flag_parse_init_performed_) {</span>
<span class="lineNum">    4115 </span><span class="lineNoCov">          0 :     post_flag_parse_init_performed_ = true;</span>
<span class="lineNum">    4116 </span>            : 
<span class="lineNum">    4117 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">    4118 </span><span class="lineNoCov">          0 :     InitDeathTestSubprocessControlInfo();</span>
<span class="lineNum">    4119 </span><span class="lineNoCov">          0 :     SuppressTestEventsIfInSubprocess();</span>
<span class="lineNum">    4120 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">    4121 </span>            : 
<span class="lineNum">    4122 </span>            :     // Registers parameterized tests. This makes parameterized tests
<span class="lineNum">    4123 </span>            :     // available to the UnitTest reflection API without running
<span class="lineNum">    4124 </span>            :     // RUN_ALL_TESTS.
<span class="lineNum">    4125 </span><span class="lineNoCov">          0 :     RegisterParameterizedTests();</span>
<span class="lineNum">    4126 </span>            : 
<span class="lineNum">    4127 </span>            :     // Configures listeners for XML output. This makes it possible for users
<span class="lineNum">    4128 </span>            :     // to shut down the default XML output before invoking RUN_ALL_TESTS.
<span class="lineNum">    4129 </span><span class="lineNoCov">          0 :     ConfigureXmlOutput();</span>
<span class="lineNum">    4130 </span>            : 
<span class="lineNum">    4131 </span>            : #if GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    4132 </span>            :     // Configures listeners for streaming test results to the specified server.
<span class="lineNum">    4133 </span><span class="lineNoCov">          0 :     ConfigureStreamingOutput();</span>
<span class="lineNum">    4134 </span>            : #endif  // GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    4135 </span>            :   }
<span class="lineNum">    4136 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4137 </span>            : 
<span class="lineNum">    4138 </span>            : // A predicate that checks the name of a TestCase against a known
<span class="lineNum">    4139 </span>            : // value.
<span class="lineNum">    4140 </span>            : //
<span class="lineNum">    4141 </span>            : // This is used for implementation of the UnitTest class only.  We put
<span class="lineNum">    4142 </span>            : // it in the anonymous namespace to prevent polluting the outer
<span class="lineNum">    4143 </span>            : // namespace.
<a name="4144"><span class="lineNum">    4144 </span>            : //</a>
<span class="lineNum">    4145 </span>            : // TestCaseNameIs is copyable.
<span class="lineNum">    4146 </span><span class="lineNoCov">          0 : class TestCaseNameIs {</span>
<a name="4147"><span class="lineNum">    4147 </span>            :  public:</a>
<span class="lineNum">    4148 </span>            :   // Constructor.
<span class="lineNum">    4149 </span><span class="lineNoCov">          0 :   explicit TestCaseNameIs(const std::string&amp; name)</span>
<span class="lineNum">    4150 </span><span class="lineNoCov">          0 :       : name_(name) {}</span>
<a name="4151"><span class="lineNum">    4151 </span>            : </a>
<span class="lineNum">    4152 </span>            :   // Returns true iff the name of test_case matches name_.
<span class="lineNum">    4153 </span><span class="lineNoCov">          0 :   bool operator()(const TestCase* test_case) const {</span>
<span class="lineNum">    4154 </span><span class="lineNoCov">          0 :     return test_case != NULL &amp;&amp; strcmp(test_case-&gt;name(), name_.c_str()) == 0;</span>
<span class="lineNum">    4155 </span>            :   }
<span class="lineNum">    4156 </span>            : 
<span class="lineNum">    4157 </span>            :  private:
<span class="lineNum">    4158 </span>            :   std::string name_;
<span class="lineNum">    4159 </span>            : };
<span class="lineNum">    4160 </span>            : 
<span class="lineNum">    4161 </span>            : // Finds and returns a TestCase with the given name.  If one doesn't
<span class="lineNum">    4162 </span>            : // exist, creates one and returns it.  It's the CALLER'S
<span class="lineNum">    4163 </span>            : // RESPONSIBILITY to ensure that this function is only called WHEN THE
<span class="lineNum">    4164 </span>            : // TESTS ARE NOT SHUFFLED.
<span class="lineNum">    4165 </span>            : //
<span class="lineNum">    4166 </span>            : // Arguments:
<span class="lineNum">    4167 </span>            : //
<span class="lineNum">    4168 </span>            : //   test_case_name: name of the test case
<span class="lineNum">    4169 </span>            : //   type_param:     the name of the test case's type parameter, or NULL if
<span class="lineNum">    4170 </span>            : //                   this is not a typed or a type-parameterized test case.
<a name="4171"><span class="lineNum">    4171 </span>            : //   set_up_tc:      pointer to the function that sets up the test case</a>
<span class="lineNum">    4172 </span>            : //   tear_down_tc:   pointer to the function that tears down the test case
<span class="lineNum">    4173 </span><span class="lineNoCov">          0 : TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,</span>
<span class="lineNum">    4174 </span>            :                                     const char* type_param,
<span class="lineNum">    4175 </span>            :                                     Test::SetUpTestCaseFunc set_up_tc,
<span class="lineNum">    4176 </span>            :                                     Test::TearDownTestCaseFunc tear_down_tc) {
<span class="lineNum">    4177 </span>            :   // Can we find a TestCase with the given name?
<span class="lineNum">    4178 </span>            :   const std::vector&lt;TestCase*&gt;::const_iterator test_case =
<span class="lineNum">    4179 </span><span class="lineNoCov">          0 :       std::find_if(test_cases_.begin(), test_cases_.end(),</span>
<span class="lineNum">    4180 </span><span class="lineNoCov">          0 :                    TestCaseNameIs(test_case_name));</span>
<span class="lineNum">    4181 </span>            : 
<span class="lineNum">    4182 </span><span class="lineNoCov">          0 :   if (test_case != test_cases_.end())</span>
<span class="lineNum">    4183 </span><span class="lineNoCov">          0 :     return *test_case;</span>
<span class="lineNum">    4184 </span>            : 
<span class="lineNum">    4185 </span>            :   // No.  Let's create one.
<span class="lineNum">    4186 </span>            :   TestCase* const new_test_case =
<span class="lineNum">    4187 </span><span class="lineNoCov">          0 :       new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);</span>
<span class="lineNum">    4188 </span>            : 
<span class="lineNum">    4189 </span>            :   // Is this a death test case?
<span class="lineNum">    4190 </span><span class="lineNoCov">          0 :   if (internal::UnitTestOptions::MatchesFilter(test_case_name,</span>
<span class="lineNum">    4191 </span>            :                                                kDeathTestCaseFilter)) {
<span class="lineNum">    4192 </span>            :     // Yes.  Inserts the test case after the last death test case
<span class="lineNum">    4193 </span>            :     // defined so far.  This only works when the test cases haven't
<span class="lineNum">    4194 </span>            :     // been shuffled.  Otherwise we may end up running a death test
<span class="lineNum">    4195 </span>            :     // after a non-death test.
<span class="lineNum">    4196 </span><span class="lineNoCov">          0 :     ++last_death_test_case_;</span>
<span class="lineNum">    4197 </span><span class="lineNoCov">          0 :     test_cases_.insert(test_cases_.begin() + last_death_test_case_,</span>
<span class="lineNum">    4198 </span><span class="lineNoCov">          0 :                        new_test_case);</span>
<span class="lineNum">    4199 </span>            :   } else {
<span class="lineNum">    4200 </span>            :     // No.  Appends to the end of the list.
<span class="lineNum">    4201 </span><span class="lineNoCov">          0 :     test_cases_.push_back(new_test_case);</span>
<span class="lineNum">    4202 </span>            :   }
<span class="lineNum">    4203 </span>            : 
<span class="lineNum">    4204 </span><span class="lineNoCov">          0 :   test_case_indices_.push_back(static_cast&lt;int&gt;(test_case_indices_.size()));</span>
<span class="lineNum">    4205 </span><span class="lineNoCov">          0 :   return new_test_case;</span>
<span class="lineNum">    4206 </span>            : }
<span class="lineNum">    4207 </span>            : 
<a name="4208"><span class="lineNum">    4208 </span>            : // Helpers for setting up / tearing down the given environment.  They</a>
<a name="4209"><span class="lineNum">    4209 </span>            : // are for use in the ForEach() function.</a>
<span class="lineNum">    4210 </span><span class="lineNoCov">          0 : static void SetUpEnvironment(Environment* env) { env-&gt;SetUp(); }</span>
<span class="lineNum">    4211 </span><span class="lineNoCov">          0 : static void TearDownEnvironment(Environment* env) { env-&gt;TearDown(); }</span>
<span class="lineNum">    4212 </span>            : 
<span class="lineNum">    4213 </span>            : // Runs all tests in this UnitTest object, prints the result, and
<span class="lineNum">    4214 </span>            : // returns true if all tests are successful.  If any exception is
<span class="lineNum">    4215 </span>            : // thrown during a test, the test is considered to be failed, but the
<span class="lineNum">    4216 </span>            : // rest of the tests will still be run.
<span class="lineNum">    4217 </span>            : //
<span class="lineNum">    4218 </span>            : // When parameterized tests are enabled, it expands and registers
<span class="lineNum">    4219 </span>            : // parameterized tests first in RegisterParameterizedTests().
<a name="4220"><span class="lineNum">    4220 </span>            : // All other functions called from RunAllTests() may safely assume that</a>
<span class="lineNum">    4221 </span>            : // parameterized tests are ready to be counted and run.
<span class="lineNum">    4222 </span><span class="lineNoCov">          0 : bool UnitTestImpl::RunAllTests() {</span>
<span class="lineNum">    4223 </span>            :   // Makes sure InitGoogleTest() was called.
<span class="lineNum">    4224 </span><span class="lineNoCov">          0 :   if (!GTestIsInitialized()) {</span>
<span class="lineNum">    4225 </span>            :     printf(&quot;%s&quot;,
<span class="lineNum">    4226 </span>            :            &quot;\nThis test program did NOT call ::testing::InitGoogleTest &quot;
<span class="lineNum">    4227 </span><span class="lineNoCov">          0 :            &quot;before calling RUN_ALL_TESTS().  Please fix it.\n&quot;);</span>
<span class="lineNum">    4228 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    4229 </span>            :   }
<span class="lineNum">    4230 </span>            : 
<span class="lineNum">    4231 </span>            :   // Do not run any test if the --help flag was specified.
<span class="lineNum">    4232 </span><span class="lineNoCov">          0 :   if (g_help_flag)</span>
<span class="lineNum">    4233 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">    4234 </span>            : 
<span class="lineNum">    4235 </span>            :   // Repeats the call to the post-flag parsing initialization in case the
<span class="lineNum">    4236 </span>            :   // user didn't call InitGoogleTest.
<span class="lineNum">    4237 </span><span class="lineNoCov">          0 :   PostFlagParsingInit();</span>
<span class="lineNum">    4238 </span>            : 
<span class="lineNum">    4239 </span>            :   // Even if sharding is not on, test runners may want to use the
<span class="lineNum">    4240 </span>            :   // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
<span class="lineNum">    4241 </span>            :   // protocol.
<span class="lineNum">    4242 </span><span class="lineNoCov">          0 :   internal::WriteToShardStatusFileIfNeeded();</span>
<span class="lineNum">    4243 </span>            : 
<span class="lineNum">    4244 </span>            :   // True iff we are in a subprocess for running a thread-safe-style
<span class="lineNum">    4245 </span>            :   // death test.
<span class="lineNum">    4246 </span><span class="lineNoCov">          0 :   bool in_subprocess_for_death_test = false;</span>
<span class="lineNum">    4247 </span>            : 
<span class="lineNum">    4248 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">    4249 </span><span class="lineNoCov">          0 :   in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);</span>
<span class="lineNum">    4250 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">    4251 </span>            : 
<span class="lineNum">    4252 </span><span class="lineNoCov">          0 :   const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,</span>
<span class="lineNum">    4253 </span><span class="lineNoCov">          0 :                                         in_subprocess_for_death_test);</span>
<span class="lineNum">    4254 </span>            : 
<span class="lineNum">    4255 </span>            :   // Compares the full test names with the filter to decide which
<span class="lineNum">    4256 </span>            :   // tests to run.
<span class="lineNum">    4257 </span><span class="lineNoCov">          0 :   const bool has_tests_to_run = FilterTests(should_shard</span>
<span class="lineNum">    4258 </span>            :                                               ? HONOR_SHARDING_PROTOCOL
<span class="lineNum">    4259 </span><span class="lineNoCov">          0 :                                               : IGNORE_SHARDING_PROTOCOL) &gt; 0;</span>
<span class="lineNum">    4260 </span>            : 
<span class="lineNum">    4261 </span>            :   // Lists the tests and exits if the --gtest_list_tests flag was specified.
<span class="lineNum">    4262 </span><span class="lineNoCov">          0 :   if (GTEST_FLAG(list_tests)) {</span>
<span class="lineNum">    4263 </span>            :     // This must be called *after* FilterTests() has been called.
<span class="lineNum">    4264 </span><span class="lineNoCov">          0 :     ListTestsMatchingFilter();</span>
<span class="lineNum">    4265 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">    4266 </span>            :   }
<span class="lineNum">    4267 </span>            : 
<span class="lineNum">    4268 </span>            :   random_seed_ = GTEST_FLAG(shuffle) ?
<span class="lineNum">    4269 </span><span class="lineNoCov">          0 :       GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;</span>
<span class="lineNum">    4270 </span>            : 
<span class="lineNum">    4271 </span>            :   // True iff at least one test has failed.
<span class="lineNum">    4272 </span><span class="lineNoCov">          0 :   bool failed = false;</span>
<span class="lineNum">    4273 </span>            : 
<span class="lineNum">    4274 </span><span class="lineNoCov">          0 :   TestEventListener* repeater = listeners()-&gt;repeater();</span>
<span class="lineNum">    4275 </span>            : 
<span class="lineNum">    4276 </span><span class="lineNoCov">          0 :   start_timestamp_ = GetTimeInMillis();</span>
<span class="lineNum">    4277 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestProgramStart(*parent_);</span>
<span class="lineNum">    4278 </span>            : 
<span class="lineNum">    4279 </span>            :   // How many times to repeat the tests?  We don't want to repeat them
<span class="lineNum">    4280 </span>            :   // when we are inside the subprocess of a death test.
<span class="lineNum">    4281 </span><span class="lineNoCov">          0 :   const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);</span>
<span class="lineNum">    4282 </span>            :   // Repeats forever if the repeat count is negative.
<span class="lineNum">    4283 </span><span class="lineNoCov">          0 :   const bool forever = repeat &lt; 0;</span>
<span class="lineNum">    4284 </span><span class="lineNoCov">          0 :   for (int i = 0; forever || i != repeat; i++) {</span>
<span class="lineNum">    4285 </span>            :     // We want to preserve failures generated by ad-hoc test
<span class="lineNum">    4286 </span>            :     // assertions executed before RUN_ALL_TESTS().
<span class="lineNum">    4287 </span><span class="lineNoCov">          0 :     ClearNonAdHocTestResult();</span>
<span class="lineNum">    4288 </span>            : 
<span class="lineNum">    4289 </span><span class="lineNoCov">          0 :     const TimeInMillis start = GetTimeInMillis();</span>
<span class="lineNum">    4290 </span>            : 
<span class="lineNum">    4291 </span>            :     // Shuffles test cases and tests if requested.
<span class="lineNum">    4292 </span><span class="lineNoCov">          0 :     if (has_tests_to_run &amp;&amp; GTEST_FLAG(shuffle)) {</span>
<span class="lineNum">    4293 </span><span class="lineNoCov">          0 :       random()-&gt;Reseed(random_seed_);</span>
<span class="lineNum">    4294 </span>            :       // This should be done before calling OnTestIterationStart(),
<span class="lineNum">    4295 </span>            :       // such that a test event listener can see the actual test order
<span class="lineNum">    4296 </span>            :       // in the event.
<span class="lineNum">    4297 </span><span class="lineNoCov">          0 :       ShuffleTests();</span>
<span class="lineNum">    4298 </span>            :     }
<span class="lineNum">    4299 </span>            : 
<span class="lineNum">    4300 </span>            :     // Tells the unit test event listeners that the tests are about to start.
<span class="lineNum">    4301 </span><span class="lineNoCov">          0 :     repeater-&gt;OnTestIterationStart(*parent_, i);</span>
<span class="lineNum">    4302 </span>            : 
<span class="lineNum">    4303 </span>            :     // Runs each test case if there is at least one test to run.
<span class="lineNum">    4304 </span><span class="lineNoCov">          0 :     if (has_tests_to_run) {</span>
<span class="lineNum">    4305 </span>            :       // Sets up all environments beforehand.
<span class="lineNum">    4306 </span><span class="lineNoCov">          0 :       repeater-&gt;OnEnvironmentsSetUpStart(*parent_);</span>
<span class="lineNum">    4307 </span><span class="lineNoCov">          0 :       ForEach(environments_, SetUpEnvironment);</span>
<span class="lineNum">    4308 </span><span class="lineNoCov">          0 :       repeater-&gt;OnEnvironmentsSetUpEnd(*parent_);</span>
<span class="lineNum">    4309 </span>            : 
<span class="lineNum">    4310 </span>            :       // Runs the tests only if there was no fatal failure during global
<span class="lineNum">    4311 </span>            :       // set-up.
<span class="lineNum">    4312 </span><span class="lineNoCov">          0 :       if (!Test::HasFatalFailure()) {</span>
<span class="lineNum">    4313 </span><span class="lineNoCov">          0 :         for (int test_index = 0; test_index &lt; total_test_case_count();</span>
<span class="lineNum">    4314 </span>            :              test_index++) {
<span class="lineNum">    4315 </span><span class="lineNoCov">          0 :           GetMutableTestCase(test_index)-&gt;Run();</span>
<span class="lineNum">    4316 </span>            :         }
<span class="lineNum">    4317 </span>            :       }
<span class="lineNum">    4318 </span>            : 
<span class="lineNum">    4319 </span>            :       // Tears down all environments in reverse order afterwards.
<span class="lineNum">    4320 </span><span class="lineNoCov">          0 :       repeater-&gt;OnEnvironmentsTearDownStart(*parent_);</span>
<span class="lineNum">    4321 </span><span class="lineNoCov">          0 :       std::for_each(environments_.rbegin(), environments_.rend(),</span>
<span class="lineNum">    4322 </span><span class="lineNoCov">          0 :                     TearDownEnvironment);</span>
<span class="lineNum">    4323 </span><span class="lineNoCov">          0 :       repeater-&gt;OnEnvironmentsTearDownEnd(*parent_);</span>
<span class="lineNum">    4324 </span>            :     }
<span class="lineNum">    4325 </span>            : 
<span class="lineNum">    4326 </span><span class="lineNoCov">          0 :     elapsed_time_ = GetTimeInMillis() - start;</span>
<span class="lineNum">    4327 </span>            : 
<span class="lineNum">    4328 </span>            :     // Tells the unit test event listener that the tests have just finished.
<span class="lineNum">    4329 </span><span class="lineNoCov">          0 :     repeater-&gt;OnTestIterationEnd(*parent_, i);</span>
<span class="lineNum">    4330 </span>            : 
<span class="lineNum">    4331 </span>            :     // Gets the result and clears it.
<span class="lineNum">    4332 </span><span class="lineNoCov">          0 :     if (!Passed()) {</span>
<span class="lineNum">    4333 </span><span class="lineNoCov">          0 :       failed = true;</span>
<span class="lineNum">    4334 </span>            :     }
<span class="lineNum">    4335 </span>            : 
<span class="lineNum">    4336 </span>            :     // Restores the original test order after the iteration.  This
<span class="lineNum">    4337 </span>            :     // allows the user to quickly repro a failure that happens in the
<span class="lineNum">    4338 </span>            :     // N-th iteration without repeating the first (N - 1) iterations.
<span class="lineNum">    4339 </span>            :     // This is not enclosed in &quot;if (GTEST_FLAG(shuffle)) { ... }&quot;, in
<span class="lineNum">    4340 </span>            :     // case the user somehow changes the value of the flag somewhere
<span class="lineNum">    4341 </span>            :     // (it's always safe to unshuffle the tests).
<span class="lineNum">    4342 </span><span class="lineNoCov">          0 :     UnshuffleTests();</span>
<span class="lineNum">    4343 </span>            : 
<span class="lineNum">    4344 </span><span class="lineNoCov">          0 :     if (GTEST_FLAG(shuffle)) {</span>
<span class="lineNum">    4345 </span>            :       // Picks a new random seed for each iteration.
<span class="lineNum">    4346 </span><span class="lineNoCov">          0 :       random_seed_ = GetNextRandomSeed(random_seed_);</span>
<span class="lineNum">    4347 </span>            :     }
<span class="lineNum">    4348 </span>            :   }
<span class="lineNum">    4349 </span>            : 
<span class="lineNum">    4350 </span><span class="lineNoCov">          0 :   repeater-&gt;OnTestProgramEnd(*parent_);</span>
<span class="lineNum">    4351 </span>            : 
<span class="lineNum">    4352 </span><span class="lineNoCov">          0 :   return !failed;</span>
<span class="lineNum">    4353 </span>            : }
<span class="lineNum">    4354 </span>            : 
<span class="lineNum">    4355 </span>            : // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
<span class="lineNum">    4356 </span>            : // if the variable is present. If a file already exists at this location, this
<a name="4357"><span class="lineNum">    4357 </span>            : // function will write over it. If the variable is present, but the file cannot</a>
<span class="lineNum">    4358 </span>            : // be created, prints an error and exits.
<span class="lineNum">    4359 </span><span class="lineNoCov">          0 : void WriteToShardStatusFileIfNeeded() {</span>
<span class="lineNum">    4360 </span><span class="lineNoCov">          0 :   const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);</span>
<span class="lineNum">    4361 </span><span class="lineNoCov">          0 :   if (test_shard_file != NULL) {</span>
<span class="lineNum">    4362 </span><span class="lineNoCov">          0 :     FILE* const file = posix::FOpen(test_shard_file, &quot;w&quot;);</span>
<span class="lineNum">    4363 </span><span class="lineNoCov">          0 :     if (file == NULL) {</span>
<span class="lineNum">    4364 </span>            :       ColoredPrintf(COLOR_RED,
<span class="lineNum">    4365 </span>            :                     &quot;Could not write to the test shard status file \&quot;%s\&quot; &quot;
<span class="lineNum">    4366 </span>            :                     &quot;specified by the %s environment variable.\n&quot;,
<span class="lineNum">    4367 </span><span class="lineNoCov">          0 :                     test_shard_file, kTestShardStatusFile);</span>
<span class="lineNum">    4368 </span><span class="lineNoCov">          0 :       fflush(stdout);</span>
<span class="lineNum">    4369 </span><span class="lineNoCov">          0 :       exit(EXIT_FAILURE);</span>
<span class="lineNum">    4370 </span>            :     }
<span class="lineNum">    4371 </span><span class="lineNoCov">          0 :     fclose(file);</span>
<span class="lineNum">    4372 </span>            :   }
<span class="lineNum">    4373 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4374 </span>            : 
<span class="lineNum">    4375 </span>            : // Checks whether sharding is enabled by examining the relevant
<span class="lineNum">    4376 </span>            : // environment variable values. If the variables are present,
<span class="lineNum">    4377 </span>            : // but inconsistent (i.e., shard_index &gt;= total_shards), prints
<span class="lineNum">    4378 </span>            : // an error and exits. If in_subprocess_for_death_test, sharding is
<a name="4379"><span class="lineNum">    4379 </span>            : // disabled because it must only be applied to the original test</a>
<span class="lineNum">    4380 </span>            : // process. Otherwise, we could filter out death tests we intended to execute.
<span class="lineNum">    4381 </span><span class="lineNoCov">          0 : bool ShouldShard(const char* total_shards_env,</span>
<span class="lineNum">    4382 </span>            :                  const char* shard_index_env,
<span class="lineNum">    4383 </span>            :                  bool in_subprocess_for_death_test) {
<span class="lineNum">    4384 </span><span class="lineNoCov">          0 :   if (in_subprocess_for_death_test) {</span>
<span class="lineNum">    4385 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    4386 </span>            :   }
<span class="lineNum">    4387 </span>            : 
<span class="lineNum">    4388 </span><span class="lineNoCov">          0 :   const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);</span>
<span class="lineNum">    4389 </span><span class="lineNoCov">          0 :   const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);</span>
<span class="lineNum">    4390 </span>            : 
<span class="lineNum">    4391 </span><span class="lineNoCov">          0 :   if (total_shards == -1 &amp;&amp; shard_index == -1) {</span>
<span class="lineNum">    4392 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    4393 </span><span class="lineNoCov">          0 :   } else if (total_shards == -1 &amp;&amp; shard_index != -1) {</span>
<span class="lineNum">    4394 </span>            :     const Message msg = Message()
<span class="lineNum">    4395 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Invalid environment variables: you have &quot;</span>
<span class="lineNum">    4396 </span><span class="lineNoCov">          0 :       &lt;&lt; kTestShardIndex &lt;&lt; &quot; = &quot; &lt;&lt; shard_index</span>
<span class="lineNum">    4397 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;, but have left &quot; &lt;&lt; kTestTotalShards &lt;&lt; &quot; unset.\n&quot;;</span>
<span class="lineNum">    4398 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_RED, msg.GetString().c_str());</span>
<span class="lineNum">    4399 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">    4400 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    4401 </span><span class="lineNoCov">          0 :   } else if (total_shards != -1 &amp;&amp; shard_index == -1) {</span>
<span class="lineNum">    4402 </span>            :     const Message msg = Message()
<span class="lineNum">    4403 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Invalid environment variables: you have &quot;</span>
<span class="lineNum">    4404 </span><span class="lineNoCov">          0 :       &lt;&lt; kTestTotalShards &lt;&lt; &quot; = &quot; &lt;&lt; total_shards</span>
<span class="lineNum">    4405 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;, but have left &quot; &lt;&lt; kTestShardIndex &lt;&lt; &quot; unset.\n&quot;;</span>
<span class="lineNum">    4406 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_RED, msg.GetString().c_str());</span>
<span class="lineNum">    4407 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">    4408 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    4409 </span><span class="lineNoCov">          0 :   } else if (shard_index &lt; 0 || shard_index &gt;= total_shards) {</span>
<span class="lineNum">    4410 </span>            :     const Message msg = Message()
<span class="lineNum">    4411 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;Invalid environment variables: we require 0 &lt;= &quot;</span>
<span class="lineNum">    4412 </span><span class="lineNoCov">          0 :       &lt;&lt; kTestShardIndex &lt;&lt; &quot; &lt; &quot; &lt;&lt; kTestTotalShards</span>
<span class="lineNum">    4413 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;, but you have &quot; &lt;&lt; kTestShardIndex &lt;&lt; &quot;=&quot; &lt;&lt; shard_index</span>
<span class="lineNum">    4414 </span><span class="lineNoCov">          0 :       &lt;&lt; &quot;, &quot; &lt;&lt; kTestTotalShards &lt;&lt; &quot;=&quot; &lt;&lt; total_shards &lt;&lt; &quot;.\n&quot;;</span>
<span class="lineNum">    4415 </span><span class="lineNoCov">          0 :     ColoredPrintf(COLOR_RED, msg.GetString().c_str());</span>
<span class="lineNum">    4416 </span><span class="lineNoCov">          0 :     fflush(stdout);</span>
<span class="lineNum">    4417 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    4418 </span>            :   }
<span class="lineNum">    4419 </span>            : 
<span class="lineNum">    4420 </span><span class="lineNoCov">          0 :   return total_shards &gt; 1;</span>
<span class="lineNum">    4421 </span>            : }
<span class="lineNum">    4422 </span>            : 
<span class="lineNum">    4423 </span>            : // Parses the environment variable var as an Int32. If it is unset,
<a name="4424"><span class="lineNum">    4424 </span>            : // returns default_val. If it is not an Int32, prints an error</a>
<span class="lineNum">    4425 </span>            : // and aborts.
<span class="lineNum">    4426 </span><span class="lineNoCov">          0 : Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {</span>
<span class="lineNum">    4427 </span><span class="lineNoCov">          0 :   const char* str_val = posix::GetEnv(var);</span>
<span class="lineNum">    4428 </span><span class="lineNoCov">          0 :   if (str_val == NULL) {</span>
<span class="lineNum">    4429 </span><span class="lineNoCov">          0 :     return default_val;</span>
<span class="lineNum">    4430 </span>            :   }
<span class="lineNum">    4431 </span>            : 
<span class="lineNum">    4432 </span>            :   Int32 result;
<span class="lineNum">    4433 </span><span class="lineNoCov">          0 :   if (!ParseInt32(Message() &lt;&lt; &quot;The value of environment variable &quot; &lt;&lt; var,</span>
<span class="lineNum">    4434 </span>            :                   str_val, &amp;result)) {
<span class="lineNum">    4435 </span><span class="lineNoCov">          0 :     exit(EXIT_FAILURE);</span>
<span class="lineNum">    4436 </span>            :   }
<span class="lineNum">    4437 </span><span class="lineNoCov">          0 :   return result;</span>
<span class="lineNum">    4438 </span>            : }
<span class="lineNum">    4439 </span>            : 
<span class="lineNum">    4440 </span>            : // Given the total number of shards, the shard index, and the test id,
<span class="lineNum">    4441 </span>            : // returns true iff the test should be run on this shard. The test id is
<a name="4442"><span class="lineNum">    4442 </span>            : // some arbitrary but unique non-negative integer assigned to each test</a>
<span class="lineNum">    4443 </span>            : // method. Assumes that 0 &lt;= shard_index &lt; total_shards.
<span class="lineNum">    4444 </span><span class="lineNoCov">          0 : bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {</span>
<span class="lineNum">    4445 </span><span class="lineNoCov">          0 :   return (test_id % total_shards) == shard_index;</span>
<span class="lineNum">    4446 </span>            : }
<span class="lineNum">    4447 </span>            : 
<span class="lineNum">    4448 </span>            : // Compares the name of each test with the user-specified filter to
<span class="lineNum">    4449 </span>            : // decide whether the test should be run, then records the result in
<span class="lineNum">    4450 </span>            : // each TestCase and TestInfo object.
<span class="lineNum">    4451 </span>            : // If shard_tests == true, further filters tests based on sharding
<span class="lineNum">    4452 </span>            : // variables in the environment - see
<a name="4453"><span class="lineNum">    4453 </span>            : // http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.</a>
<span class="lineNum">    4454 </span>            : // Returns the number of tests that should run.
<span class="lineNum">    4455 </span><span class="lineNoCov">          0 : int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {</span>
<span class="lineNum">    4456 </span>            :   const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
<span class="lineNum">    4457 </span><span class="lineNoCov">          0 :       Int32FromEnvOrDie(kTestTotalShards, -1) : -1;</span>
<span class="lineNum">    4458 </span>            :   const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
<span class="lineNum">    4459 </span><span class="lineNoCov">          0 :       Int32FromEnvOrDie(kTestShardIndex, -1) : -1;</span>
<span class="lineNum">    4460 </span>            : 
<span class="lineNum">    4461 </span>            :   // num_runnable_tests are the number of tests that will
<span class="lineNum">    4462 </span>            :   // run across all shards (i.e., match filter and are not disabled).
<span class="lineNum">    4463 </span>            :   // num_selected_tests are the number of tests to be run on
<span class="lineNum">    4464 </span>            :   // this shard.
<span class="lineNum">    4465 </span><span class="lineNoCov">          0 :   int num_runnable_tests = 0;</span>
<span class="lineNum">    4466 </span><span class="lineNoCov">          0 :   int num_selected_tests = 0;</span>
<span class="lineNum">    4467 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; test_cases_.size(); i++) {</span>
<span class="lineNum">    4468 </span><span class="lineNoCov">          0 :     TestCase* const test_case = test_cases_[i];</span>
<span class="lineNum">    4469 </span><span class="lineNoCov">          0 :     const std::string &amp;test_case_name = test_case-&gt;name();</span>
<span class="lineNum">    4470 </span><span class="lineNoCov">          0 :     test_case-&gt;set_should_run(false);</span>
<span class="lineNum">    4471 </span>            : 
<span class="lineNum">    4472 </span><span class="lineNoCov">          0 :     for (size_t j = 0; j &lt; test_case-&gt;test_info_list().size(); j++) {</span>
<span class="lineNum">    4473 </span><span class="lineNoCov">          0 :       TestInfo* const test_info = test_case-&gt;test_info_list()[j];</span>
<span class="lineNum">    4474 </span><span class="lineNoCov">          0 :       const std::string test_name(test_info-&gt;name());</span>
<span class="lineNum">    4475 </span>            :       // A test is disabled if test case name or test name matches
<span class="lineNum">    4476 </span>            :       // kDisableTestFilter.
<span class="lineNum">    4477 </span>            :       const bool is_disabled =
<span class="lineNum">    4478 </span><span class="lineNoCov">          0 :           internal::UnitTestOptions::MatchesFilter(test_case_name,</span>
<span class="lineNum">    4479 </span><span class="lineNoCov">          0 :                                                    kDisableTestFilter) ||</span>
<span class="lineNum">    4480 </span><span class="lineNoCov">          0 :           internal::UnitTestOptions::MatchesFilter(test_name,</span>
<span class="lineNum">    4481 </span><span class="lineNoCov">          0 :                                                    kDisableTestFilter);</span>
<span class="lineNum">    4482 </span><span class="lineNoCov">          0 :       test_info-&gt;is_disabled_ = is_disabled;</span>
<span class="lineNum">    4483 </span>            : 
<span class="lineNum">    4484 </span>            :       const bool matches_filter =
<span class="lineNum">    4485 </span>            :           internal::UnitTestOptions::FilterMatchesTest(test_case_name,
<span class="lineNum">    4486 </span><span class="lineNoCov">          0 :                                                        test_name);</span>
<span class="lineNum">    4487 </span><span class="lineNoCov">          0 :       test_info-&gt;matches_filter_ = matches_filter;</span>
<span class="lineNum">    4488 </span>            : 
<span class="lineNum">    4489 </span>            :       const bool is_runnable =
<span class="lineNum">    4490 </span><span class="lineNoCov">          0 :           (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &amp;&amp;</span>
<span class="lineNum">    4491 </span><span class="lineNoCov">          0 :           matches_filter;</span>
<span class="lineNum">    4492 </span>            : 
<span class="lineNum">    4493 </span><span class="lineNoCov">          0 :       const bool is_selected = is_runnable &amp;&amp;</span>
<span class="lineNum">    4494 </span><span class="lineNoCov">          0 :           (shard_tests == IGNORE_SHARDING_PROTOCOL ||</span>
<span class="lineNum">    4495 </span><span class="lineNoCov">          0 :            ShouldRunTestOnShard(total_shards, shard_index,</span>
<span class="lineNum">    4496 </span><span class="lineNoCov">          0 :                                 num_runnable_tests));</span>
<span class="lineNum">    4497 </span>            : 
<span class="lineNum">    4498 </span><span class="lineNoCov">          0 :       num_runnable_tests += is_runnable;</span>
<span class="lineNum">    4499 </span><span class="lineNoCov">          0 :       num_selected_tests += is_selected;</span>
<span class="lineNum">    4500 </span>            : 
<span class="lineNum">    4501 </span><span class="lineNoCov">          0 :       test_info-&gt;should_run_ = is_selected;</span>
<span class="lineNum">    4502 </span><span class="lineNoCov">          0 :       test_case-&gt;set_should_run(test_case-&gt;should_run() || is_selected);</span>
<span class="lineNum">    4503 </span>            :     }
<span class="lineNum">    4504 </span>            :   }
<span class="lineNum">    4505 </span><span class="lineNoCov">          0 :   return num_selected_tests;</span>
<span class="lineNum">    4506 </span>            : }
<span class="lineNum">    4507 </span>            : 
<span class="lineNum">    4508 </span>            : // Prints the given C-string on a single line by replacing all '\n'
<span class="lineNum">    4509 </span>            : // characters with string &quot;\\n&quot;.  If the output takes more than
<a name="4510"><span class="lineNum">    4510 </span>            : // max_length characters, only prints the first max_length characters</a>
<span class="lineNum">    4511 </span>            : // and &quot;...&quot;.
<span class="lineNum">    4512 </span><span class="lineNoCov">          0 : static void PrintOnOneLine(const char* str, int max_length) {</span>
<span class="lineNum">    4513 </span><span class="lineNoCov">          0 :   if (str != NULL) {</span>
<span class="lineNum">    4514 </span><span class="lineNoCov">          0 :     for (int i = 0; *str != '\0'; ++str) {</span>
<span class="lineNum">    4515 </span><span class="lineNoCov">          0 :       if (i &gt;= max_length) {</span>
<span class="lineNum">    4516 </span><span class="lineNoCov">          0 :         printf(&quot;...&quot;);</span>
<span class="lineNum">    4517 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">    4518 </span>            :       }
<span class="lineNum">    4519 </span><span class="lineNoCov">          0 :       if (*str == '\n') {</span>
<span class="lineNum">    4520 </span><span class="lineNoCov">          0 :         printf(&quot;\\n&quot;);</span>
<span class="lineNum">    4521 </span><span class="lineNoCov">          0 :         i += 2;</span>
<span class="lineNum">    4522 </span>            :       } else {
<span class="lineNum">    4523 </span><span class="lineNoCov">          0 :         printf(&quot;%c&quot;, *str);</span>
<span class="lineNum">    4524 </span><span class="lineNoCov">          0 :         ++i;</span>
<span class="lineNum">    4525 </span>            :       }
<span class="lineNum">    4526 </span>            :     }
<span class="lineNum">    4527 </span>            :   }
<span class="lineNum">    4528 </span><span class="lineNoCov">          0 : }</span>
<a name="4529"><span class="lineNum">    4529 </span>            : </a>
<span class="lineNum">    4530 </span>            : // Prints the names of the tests matching the user-specified filter flag.
<span class="lineNum">    4531 </span><span class="lineNoCov">          0 : void UnitTestImpl::ListTestsMatchingFilter() {</span>
<span class="lineNum">    4532 </span>            :   // Print at most this many characters for each type/value parameter.
<span class="lineNum">    4533 </span><span class="lineNoCov">          0 :   const int kMaxParamLength = 250;</span>
<span class="lineNum">    4534 </span>            : 
<span class="lineNum">    4535 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; test_cases_.size(); i++) {</span>
<span class="lineNum">    4536 </span><span class="lineNoCov">          0 :     const TestCase* const test_case = test_cases_[i];</span>
<span class="lineNum">    4537 </span><span class="lineNoCov">          0 :     bool printed_test_case_name = false;</span>
<span class="lineNum">    4538 </span>            : 
<span class="lineNum">    4539 </span><span class="lineNoCov">          0 :     for (size_t j = 0; j &lt; test_case-&gt;test_info_list().size(); j++) {</span>
<span class="lineNum">    4540 </span>            :       const TestInfo* const test_info =
<span class="lineNum">    4541 </span><span class="lineNoCov">          0 :           test_case-&gt;test_info_list()[j];</span>
<span class="lineNum">    4542 </span><span class="lineNoCov">          0 :       if (test_info-&gt;matches_filter_) {</span>
<span class="lineNum">    4543 </span><span class="lineNoCov">          0 :         if (!printed_test_case_name) {</span>
<span class="lineNum">    4544 </span><span class="lineNoCov">          0 :           printed_test_case_name = true;</span>
<span class="lineNum">    4545 </span><span class="lineNoCov">          0 :           printf(&quot;%s.&quot;, test_case-&gt;name());</span>
<span class="lineNum">    4546 </span><span class="lineNoCov">          0 :           if (test_case-&gt;type_param() != NULL) {</span>
<span class="lineNum">    4547 </span><span class="lineNoCov">          0 :             printf(&quot;  # %s = &quot;, kTypeParamLabel);</span>
<span class="lineNum">    4548 </span>            :             // We print the type parameter on a single line to make
<span class="lineNum">    4549 </span>            :             // the output easy to parse by a program.
<span class="lineNum">    4550 </span><span class="lineNoCov">          0 :             PrintOnOneLine(test_case-&gt;type_param(), kMaxParamLength);</span>
<span class="lineNum">    4551 </span>            :           }
<span class="lineNum">    4552 </span><span class="lineNoCov">          0 :           printf(&quot;\n&quot;);</span>
<span class="lineNum">    4553 </span>            :         }
<span class="lineNum">    4554 </span><span class="lineNoCov">          0 :         printf(&quot;  %s&quot;, test_info-&gt;name());</span>
<span class="lineNum">    4555 </span><span class="lineNoCov">          0 :         if (test_info-&gt;value_param() != NULL) {</span>
<span class="lineNum">    4556 </span><span class="lineNoCov">          0 :           printf(&quot;  # %s = &quot;, kValueParamLabel);</span>
<span class="lineNum">    4557 </span>            :           // We print the value parameter on a single line to make the
<span class="lineNum">    4558 </span>            :           // output easy to parse by a program.
<span class="lineNum">    4559 </span><span class="lineNoCov">          0 :           PrintOnOneLine(test_info-&gt;value_param(), kMaxParamLength);</span>
<span class="lineNum">    4560 </span>            :         }
<span class="lineNum">    4561 </span><span class="lineNoCov">          0 :         printf(&quot;\n&quot;);</span>
<span class="lineNum">    4562 </span>            :       }
<span class="lineNum">    4563 </span>            :     }
<span class="lineNum">    4564 </span>            :   }
<span class="lineNum">    4565 </span><span class="lineNoCov">          0 :   fflush(stdout);</span>
<span class="lineNum">    4566 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4567 </span>            : 
<span class="lineNum">    4568 </span>            : // Sets the OS stack trace getter.
<span class="lineNum">    4569 </span>            : //
<span class="lineNum">    4570 </span>            : // Does nothing if the input and the current OS stack trace getter are
<a name="4571"><span class="lineNum">    4571 </span>            : // the same; otherwise, deletes the old getter and makes the input the</a>
<span class="lineNum">    4572 </span>            : // current getter.
<span class="lineNum">    4573 </span><span class="lineNoCov">          0 : void UnitTestImpl::set_os_stack_trace_getter(</span>
<span class="lineNum">    4574 </span>            :     OsStackTraceGetterInterface* getter) {
<span class="lineNum">    4575 </span><span class="lineNoCov">          0 :   if (os_stack_trace_getter_ != getter) {</span>
<span class="lineNum">    4576 </span><span class="lineNoCov">          0 :     delete os_stack_trace_getter_;</span>
<span class="lineNum">    4577 </span><span class="lineNoCov">          0 :     os_stack_trace_getter_ = getter;</span>
<span class="lineNum">    4578 </span>            :   }
<span class="lineNum">    4579 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4580 </span>            : 
<span class="lineNum">    4581 </span>            : // Returns the current OS stack trace getter if it is not NULL;
<a name="4582"><span class="lineNum">    4582 </span>            : // otherwise, creates an OsStackTraceGetter, makes it the current</a>
<span class="lineNum">    4583 </span>            : // getter, and returns it.
<span class="lineNum">    4584 </span><span class="lineNoCov">          0 : OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {</span>
<span class="lineNum">    4585 </span><span class="lineNoCov">          0 :   if (os_stack_trace_getter_ == NULL) {</span>
<span class="lineNum">    4586 </span><span class="lineNoCov">          0 :     os_stack_trace_getter_ = new OsStackTraceGetter;</span>
<span class="lineNum">    4587 </span>            :   }
<span class="lineNum">    4588 </span>            : 
<span class="lineNum">    4589 </span><span class="lineNoCov">          0 :   return os_stack_trace_getter_;</span>
<span class="lineNum">    4590 </span>            : }
<span class="lineNum">    4591 </span>            : 
<a name="4592"><span class="lineNum">    4592 </span>            : // Returns the TestResult for the test that's currently running, or</a>
<span class="lineNum">    4593 </span>            : // the TestResult for the ad hoc test if no test is running.
<span class="lineNum">    4594 </span><span class="lineNoCov">          0 : TestResult* UnitTestImpl::current_test_result() {</span>
<span class="lineNum">    4595 </span><span class="lineNoCov">          0 :   return current_test_info_ ?</span>
<span class="lineNum">    4596 </span><span class="lineNoCov">          0 :       &amp;(current_test_info_-&gt;result_) : &amp;ad_hoc_test_result_;</span>
<span class="lineNum">    4597 </span>            : }
<span class="lineNum">    4598 </span>            : 
<a name="4599"><span class="lineNum">    4599 </span>            : // Shuffles all test cases, and the tests within each test case,</a>
<span class="lineNum">    4600 </span>            : // making sure that death tests are still run first.
<span class="lineNum">    4601 </span><span class="lineNoCov">          0 : void UnitTestImpl::ShuffleTests() {</span>
<span class="lineNum">    4602 </span>            :   // Shuffles the death test cases.
<span class="lineNum">    4603 </span><span class="lineNoCov">          0 :   ShuffleRange(random(), 0, last_death_test_case_ + 1, &amp;test_case_indices_);</span>
<span class="lineNum">    4604 </span>            : 
<span class="lineNum">    4605 </span>            :   // Shuffles the non-death test cases.
<span class="lineNum">    4606 </span><span class="lineNoCov">          0 :   ShuffleRange(random(), last_death_test_case_ + 1,</span>
<span class="lineNum">    4607 </span><span class="lineNoCov">          0 :                static_cast&lt;int&gt;(test_cases_.size()), &amp;test_case_indices_);</span>
<span class="lineNum">    4608 </span>            : 
<span class="lineNum">    4609 </span>            :   // Shuffles the tests inside each test case.
<span class="lineNum">    4610 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; test_cases_.size(); i++) {</span>
<span class="lineNum">    4611 </span><span class="lineNoCov">          0 :     test_cases_[i]-&gt;ShuffleTests(random());</span>
<span class="lineNum">    4612 </span>            :   }
<span class="lineNum">    4613 </span><span class="lineNoCov">          0 : }</span>
<a name="4614"><span class="lineNum">    4614 </span>            : </a>
<span class="lineNum">    4615 </span>            : // Restores the test cases and tests to their order before the first shuffle.
<span class="lineNum">    4616 </span><span class="lineNoCov">          0 : void UnitTestImpl::UnshuffleTests() {</span>
<span class="lineNum">    4617 </span><span class="lineNoCov">          0 :   for (size_t i = 0; i &lt; test_cases_.size(); i++) {</span>
<span class="lineNum">    4618 </span>            :     // Unshuffles the tests in each test case.
<span class="lineNum">    4619 </span><span class="lineNoCov">          0 :     test_cases_[i]-&gt;UnshuffleTests();</span>
<span class="lineNum">    4620 </span>            :     // Resets the index of each test case.
<span class="lineNum">    4621 </span><span class="lineNoCov">          0 :     test_case_indices_[i] = static_cast&lt;int&gt;(i);</span>
<span class="lineNum">    4622 </span>            :   }
<span class="lineNum">    4623 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4624 </span>            : 
<span class="lineNum">    4625 </span>            : // Returns the current OS stack trace as an std::string.
<span class="lineNum">    4626 </span>            : //
<span class="lineNum">    4627 </span>            : // The maximum number of stack frames to be included is specified by
<span class="lineNum">    4628 </span>            : // the gtest_stack_trace_depth flag.  The skip_count parameter
<span class="lineNum">    4629 </span>            : // specifies the number of top frames to be skipped, which doesn't
<span class="lineNum">    4630 </span>            : // count against the number of frames to be included.
<span class="lineNum">    4631 </span>            : //
<span class="lineNum">    4632 </span>            : // For example, if Foo() calls Bar(), which in turn calls
<a name="4633"><span class="lineNum">    4633 </span>            : // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in</a>
<span class="lineNum">    4634 </span>            : // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
<span class="lineNum">    4635 </span><span class="lineNoCov">          0 : std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,</span>
<span class="lineNum">    4636 </span>            :                                             int skip_count) {
<span class="lineNum">    4637 </span>            :   // We pass skip_count + 1 to skip this wrapper function in addition
<span class="lineNum">    4638 </span>            :   // to what the user really wants to skip.
<span class="lineNum">    4639 </span><span class="lineNoCov">          0 :   return GetUnitTestImpl()-&gt;CurrentOsStackTraceExceptTop(skip_count + 1);</span>
<span class="lineNum">    4640 </span>            : }
<span class="lineNum">    4641 </span>            : 
<span class="lineNum">    4642 </span>            : // Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
<span class="lineNum">    4643 </span>            : // suppress unreachable code warnings.
<span class="lineNum">    4644 </span>            : namespace {
<span class="lineNum">    4645 </span>            : class ClassUniqueToAlwaysTrue {};
<a name="4646"><span class="lineNum">    4646 </span>            : }</a>
<span class="lineNum">    4647 </span>            : 
<a name="4648"><span class="lineNum">    4648 </span><span class="lineNoCov">          0 : bool IsTrue(bool condition) { return condition; }</span></a>
<span class="lineNum">    4649 </span>            : 
<span class="lineNum">    4650 </span><span class="lineNoCov">          0 : bool AlwaysTrue() {</span>
<span class="lineNum">    4651 </span>            : #if GTEST_HAS_EXCEPTIONS
<span class="lineNum">    4652 </span>            :   // This condition is always false so AlwaysTrue() never actually throws,
<span class="lineNum">    4653 </span>            :   // but it makes the compiler think that it may throw.
<span class="lineNum">    4654 </span><span class="lineNoCov">          0 :   if (IsTrue(false))</span>
<span class="lineNum">    4655 </span><span class="lineNoCov">          0 :     throw ClassUniqueToAlwaysTrue();</span>
<span class="lineNum">    4656 </span>            : #endif  // GTEST_HAS_EXCEPTIONS
<span class="lineNum">    4657 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    4658 </span>            : }
<span class="lineNum">    4659 </span>            : 
<span class="lineNum">    4660 </span>            : // If *pstr starts with the given prefix, modifies *pstr to be right
<a name="4661"><span class="lineNum">    4661 </span>            : // past the prefix and returns true; otherwise leaves *pstr unchanged</a>
<span class="lineNum">    4662 </span>            : // and returns false.  None of pstr, *pstr, and prefix can be NULL.
<span class="lineNum">    4663 </span><span class="lineNoCov">          0 : bool SkipPrefix(const char* prefix, const char** pstr) {</span>
<span class="lineNum">    4664 </span><span class="lineNoCov">          0 :   const size_t prefix_len = strlen(prefix);</span>
<span class="lineNum">    4665 </span><span class="lineNoCov">          0 :   if (strncmp(*pstr, prefix, prefix_len) == 0) {</span>
<span class="lineNum">    4666 </span><span class="lineNoCov">          0 :     *pstr += prefix_len;</span>
<span class="lineNum">    4667 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">    4668 </span>            :   }
<span class="lineNum">    4669 </span><span class="lineNoCov">          0 :   return false;</span>
<span class="lineNum">    4670 </span>            : }
<span class="lineNum">    4671 </span>            : 
<span class="lineNum">    4672 </span>            : // Parses a string as a command line flag.  The string should have
<span class="lineNum">    4673 </span>            : // the format &quot;--flag=value&quot;.  When def_optional is true, the &quot;=value&quot;
<span class="lineNum">    4674 </span>            : // part can be omitted.
<a name="4675"><span class="lineNum">    4675 </span>            : //</a>
<span class="lineNum">    4676 </span>            : // Returns the value of the flag, or NULL if the parsing failed.
<span class="lineNum">    4677 </span><span class="lineNoCov">          0 : const char* ParseFlagValue(const char* str,</span>
<span class="lineNum">    4678 </span>            :                            const char* flag,
<span class="lineNum">    4679 </span>            :                            bool def_optional) {
<span class="lineNum">    4680 </span>            :   // str and flag must not be NULL.
<span class="lineNum">    4681 </span><span class="lineNoCov">          0 :   if (str == NULL || flag == NULL) return NULL;</span>
<span class="lineNum">    4682 </span>            : 
<span class="lineNum">    4683 </span>            :   // The flag must start with &quot;--&quot; followed by GTEST_FLAG_PREFIX_.
<span class="lineNum">    4684 </span><span class="lineNoCov">          0 :   const std::string flag_str = std::string(&quot;--&quot;) + GTEST_FLAG_PREFIX_ + flag;</span>
<span class="lineNum">    4685 </span><span class="lineNoCov">          0 :   const size_t flag_len = flag_str.length();</span>
<span class="lineNum">    4686 </span><span class="lineNoCov">          0 :   if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;</span>
<span class="lineNum">    4687 </span>            : 
<span class="lineNum">    4688 </span>            :   // Skips the flag name.
<span class="lineNum">    4689 </span><span class="lineNoCov">          0 :   const char* flag_end = str + flag_len;</span>
<span class="lineNum">    4690 </span>            : 
<span class="lineNum">    4691 </span>            :   // When def_optional is true, it's OK to not have a &quot;=value&quot; part.
<span class="lineNum">    4692 </span><span class="lineNoCov">          0 :   if (def_optional &amp;&amp; (flag_end[0] == '\0')) {</span>
<span class="lineNum">    4693 </span><span class="lineNoCov">          0 :     return flag_end;</span>
<span class="lineNum">    4694 </span>            :   }
<span class="lineNum">    4695 </span>            : 
<span class="lineNum">    4696 </span>            :   // If def_optional is true and there are more characters after the
<span class="lineNum">    4697 </span>            :   // flag name, or if def_optional is false, there must be a '=' after
<span class="lineNum">    4698 </span>            :   // the flag name.
<span class="lineNum">    4699 </span><span class="lineNoCov">          0 :   if (flag_end[0] != '=') return NULL;</span>
<span class="lineNum">    4700 </span>            : 
<span class="lineNum">    4701 </span>            :   // Returns the string after &quot;=&quot;.
<span class="lineNum">    4702 </span><span class="lineNoCov">          0 :   return flag_end + 1;</span>
<span class="lineNum">    4703 </span>            : }
<span class="lineNum">    4704 </span>            : 
<span class="lineNum">    4705 </span>            : // Parses a string for a bool flag, in the form of either
<span class="lineNum">    4706 </span>            : // &quot;--flag=value&quot; or &quot;--flag&quot;.
<span class="lineNum">    4707 </span>            : //
<span class="lineNum">    4708 </span>            : // In the former case, the value is taken as true as long as it does
<span class="lineNum">    4709 </span>            : // not start with '0', 'f', or 'F'.
<span class="lineNum">    4710 </span>            : //
<span class="lineNum">    4711 </span>            : // In the latter case, the value is taken as true.
<span class="lineNum">    4712 </span>            : //
<a name="4713"><span class="lineNum">    4713 </span>            : // On success, stores the value of the flag in *value, and returns</a>
<span class="lineNum">    4714 </span>            : // true.  On failure, returns false without changing *value.
<span class="lineNum">    4715 </span><span class="lineNoCov">          0 : bool ParseBoolFlag(const char* str, const char* flag, bool* value) {</span>
<span class="lineNum">    4716 </span>            :   // Gets the value of the flag as a string.
<span class="lineNum">    4717 </span><span class="lineNoCov">          0 :   const char* const value_str = ParseFlagValue(str, flag, true);</span>
<span class="lineNum">    4718 </span>            : 
<span class="lineNum">    4719 </span>            :   // Aborts if the parsing failed.
<span class="lineNum">    4720 </span><span class="lineNoCov">          0 :   if (value_str == NULL) return false;</span>
<span class="lineNum">    4721 </span>            : 
<span class="lineNum">    4722 </span>            :   // Converts the string value to a bool.
<span class="lineNum">    4723 </span><span class="lineNoCov">          0 :   *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');</span>
<span class="lineNum">    4724 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    4725 </span>            : }
<span class="lineNum">    4726 </span>            : 
<span class="lineNum">    4727 </span>            : // Parses a string for an Int32 flag, in the form of
<span class="lineNum">    4728 </span>            : // &quot;--flag=value&quot;.
<span class="lineNum">    4729 </span>            : //
<a name="4730"><span class="lineNum">    4730 </span>            : // On success, stores the value of the flag in *value, and returns</a>
<span class="lineNum">    4731 </span>            : // true.  On failure, returns false without changing *value.
<span class="lineNum">    4732 </span><span class="lineNoCov">          0 : bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {</span>
<span class="lineNum">    4733 </span>            :   // Gets the value of the flag as a string.
<span class="lineNum">    4734 </span><span class="lineNoCov">          0 :   const char* const value_str = ParseFlagValue(str, flag, false);</span>
<span class="lineNum">    4735 </span>            : 
<span class="lineNum">    4736 </span>            :   // Aborts if the parsing failed.
<span class="lineNum">    4737 </span><span class="lineNoCov">          0 :   if (value_str == NULL) return false;</span>
<span class="lineNum">    4738 </span>            : 
<span class="lineNum">    4739 </span>            :   // Sets *value to the value of the flag.
<span class="lineNum">    4740 </span><span class="lineNoCov">          0 :   return ParseInt32(Message() &lt;&lt; &quot;The value of flag --&quot; &lt;&lt; flag,</span>
<span class="lineNum">    4741 </span><span class="lineNoCov">          0 :                     value_str, value);</span>
<span class="lineNum">    4742 </span>            : }
<span class="lineNum">    4743 </span>            : 
<span class="lineNum">    4744 </span>            : // Parses a string for a string flag, in the form of
<span class="lineNum">    4745 </span>            : // &quot;--flag=value&quot;.
<span class="lineNum">    4746 </span>            : //
<a name="4747"><span class="lineNum">    4747 </span>            : // On success, stores the value of the flag in *value, and returns</a>
<span class="lineNum">    4748 </span>            : // true.  On failure, returns false without changing *value.
<span class="lineNum">    4749 </span><span class="lineNoCov">          0 : bool ParseStringFlag(const char* str, const char* flag, std::string* value) {</span>
<span class="lineNum">    4750 </span>            :   // Gets the value of the flag as a string.
<span class="lineNum">    4751 </span><span class="lineNoCov">          0 :   const char* const value_str = ParseFlagValue(str, flag, false);</span>
<span class="lineNum">    4752 </span>            : 
<span class="lineNum">    4753 </span>            :   // Aborts if the parsing failed.
<span class="lineNum">    4754 </span><span class="lineNoCov">          0 :   if (value_str == NULL) return false;</span>
<span class="lineNum">    4755 </span>            : 
<span class="lineNum">    4756 </span>            :   // Sets *value to the value of the flag.
<span class="lineNum">    4757 </span><span class="lineNoCov">          0 :   *value = value_str;</span>
<span class="lineNum">    4758 </span><span class="lineNoCov">          0 :   return true;</span>
<span class="lineNum">    4759 </span>            : }
<span class="lineNum">    4760 </span>            : 
<span class="lineNum">    4761 </span>            : // Determines whether a string has a prefix that Google Test uses for its
<span class="lineNum">    4762 </span>            : // flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
<span class="lineNum">    4763 </span>            : // If Google Test detects that a command line flag has its prefix but is not
<span class="lineNum">    4764 </span>            : // recognized, it will print its help message. Flags starting with
<a name="4765"><span class="lineNum">    4765 </span>            : // GTEST_INTERNAL_PREFIX_ followed by &quot;internal_&quot; are considered Google Test</a>
<span class="lineNum">    4766 </span>            : // internal flags and do not trigger the help message.
<span class="lineNum">    4767 </span><span class="lineNoCov">          0 : static bool HasGoogleTestFlagPrefix(const char* str) {</span>
<span class="lineNum">    4768 </span><span class="lineNoCov">          0 :   return (SkipPrefix(&quot;--&quot;, &amp;str) ||</span>
<span class="lineNum">    4769 </span><span class="lineNoCov">          0 :           SkipPrefix(&quot;-&quot;, &amp;str) ||</span>
<span class="lineNum">    4770 </span><span class="lineNoCov">          0 :           SkipPrefix(&quot;/&quot;, &amp;str)) &amp;&amp;</span>
<span class="lineNum">    4771 </span><span class="lineNoCov">          0 :          !SkipPrefix(GTEST_FLAG_PREFIX_ &quot;internal_&quot;, &amp;str) &amp;&amp;</span>
<span class="lineNum">    4772 </span><span class="lineNoCov">          0 :          (SkipPrefix(GTEST_FLAG_PREFIX_, &amp;str) ||</span>
<span class="lineNum">    4773 </span><span class="lineNoCov">          0 :           SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &amp;str));</span>
<span class="lineNum">    4774 </span>            : }
<span class="lineNum">    4775 </span>            : 
<span class="lineNum">    4776 </span>            : // Prints a string containing code-encoded text.  The following escape
<span class="lineNum">    4777 </span>            : // sequences can be used in the string to control the text color:
<span class="lineNum">    4778 </span>            : //
<span class="lineNum">    4779 </span>            : //   @@    prints a single '@' character.
<span class="lineNum">    4780 </span>            : //   @R    changes the color to red.
<span class="lineNum">    4781 </span>            : //   @G    changes the color to green.
<span class="lineNum">    4782 </span>            : //   @Y    changes the color to yellow.
<span class="lineNum">    4783 </span>            : //   @D    changes to the default terminal text color.
<span class="lineNum">    4784 </span>            : //
<a name="4785"><span class="lineNum">    4785 </span>            : // TODO(wan@google.com): Write tests for this once we add stdout</a>
<span class="lineNum">    4786 </span>            : // capturing to Google Test.
<span class="lineNum">    4787 </span><span class="lineNoCov">          0 : static void PrintColorEncoded(const char* str) {</span>
<span class="lineNum">    4788 </span><span class="lineNoCov">          0 :   GTestColor color = COLOR_DEFAULT;  // The current color.</span>
<span class="lineNum">    4789 </span>            : 
<span class="lineNum">    4790 </span>            :   // Conceptually, we split the string into segments divided by escape
<span class="lineNum">    4791 </span>            :   // sequences.  Then we print one segment at a time.  At the end of
<span class="lineNum">    4792 </span>            :   // each iteration, the str pointer advances to the beginning of the
<span class="lineNum">    4793 </span>            :   // next segment.
<span class="lineNum">    4794 </span><span class="lineNoCov">          0 :   for (;;) {</span>
<span class="lineNum">    4795 </span><span class="lineNoCov">          0 :     const char* p = strchr(str, '@');</span>
<span class="lineNum">    4796 </span><span class="lineNoCov">          0 :     if (p == NULL) {</span>
<span class="lineNum">    4797 </span><span class="lineNoCov">          0 :       ColoredPrintf(color, &quot;%s&quot;, str);</span>
<span class="lineNum">    4798 </span><span class="lineNoCov">          0 :       return;</span>
<span class="lineNum">    4799 </span>            :     }
<span class="lineNum">    4800 </span>            : 
<span class="lineNum">    4801 </span><span class="lineNoCov">          0 :     ColoredPrintf(color, &quot;%s&quot;, std::string(str, p).c_str());</span>
<span class="lineNum">    4802 </span>            : 
<span class="lineNum">    4803 </span><span class="lineNoCov">          0 :     const char ch = p[1];</span>
<span class="lineNum">    4804 </span><span class="lineNoCov">          0 :     str = p + 2;</span>
<span class="lineNum">    4805 </span><span class="lineNoCov">          0 :     if (ch == '@') {</span>
<span class="lineNum">    4806 </span><span class="lineNoCov">          0 :       ColoredPrintf(color, &quot;@&quot;);</span>
<span class="lineNum">    4807 </span><span class="lineNoCov">          0 :     } else if (ch == 'D') {</span>
<span class="lineNum">    4808 </span><span class="lineNoCov">          0 :       color = COLOR_DEFAULT;</span>
<span class="lineNum">    4809 </span><span class="lineNoCov">          0 :     } else if (ch == 'R') {</span>
<span class="lineNum">    4810 </span><span class="lineNoCov">          0 :       color = COLOR_RED;</span>
<span class="lineNum">    4811 </span><span class="lineNoCov">          0 :     } else if (ch == 'G') {</span>
<span class="lineNum">    4812 </span><span class="lineNoCov">          0 :       color = COLOR_GREEN;</span>
<span class="lineNum">    4813 </span><span class="lineNoCov">          0 :     } else if (ch == 'Y') {</span>
<span class="lineNum">    4814 </span><span class="lineNoCov">          0 :       color = COLOR_YELLOW;</span>
<span class="lineNum">    4815 </span>            :     } else {
<span class="lineNum">    4816 </span><span class="lineNoCov">          0 :       --str;</span>
<span class="lineNum">    4817 </span>            :     }
<span class="lineNum">    4818 </span>            :   }
<span class="lineNum">    4819 </span>            : }
<span class="lineNum">    4820 </span>            : 
<span class="lineNum">    4821 </span>            : static const char kColorEncodedHelpMessage[] =
<span class="lineNum">    4822 </span>            : &quot;This program contains tests written using &quot; GTEST_NAME_ &quot;. You can use the\n&quot;
<span class="lineNum">    4823 </span>            : &quot;following command line flags to control its behavior:\n&quot;
<span class="lineNum">    4824 </span>            : &quot;\n&quot;
<span class="lineNum">    4825 </span>            : &quot;Test Selection:\n&quot;
<span class="lineNum">    4826 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;list_tests@D\n&quot;
<span class="lineNum">    4827 </span>            : &quot;      List the names of all tests instead of running them. The name of\n&quot;
<span class="lineNum">    4828 </span>            : &quot;      TEST(Foo, Bar) is \&quot;Foo.Bar\&quot;.\n&quot;
<span class="lineNum">    4829 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;filter=@YPOSTIVE_PATTERNS&quot;
<span class="lineNum">    4830 </span>            :     &quot;[@G-@YNEGATIVE_PATTERNS]@D\n&quot;
<span class="lineNum">    4831 </span>            : &quot;      Run only the tests whose name matches one of the positive patterns but\n&quot;
<span class="lineNum">    4832 </span>            : &quot;      none of the negative patterns. '?' matches any single character; '*'\n&quot;
<span class="lineNum">    4833 </span>            : &quot;      matches any substring; ':' separates two patterns.\n&quot;
<span class="lineNum">    4834 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;also_run_disabled_tests@D\n&quot;
<span class="lineNum">    4835 </span>            : &quot;      Run all disabled tests too.\n&quot;
<span class="lineNum">    4836 </span>            : &quot;\n&quot;
<span class="lineNum">    4837 </span>            : &quot;Test Execution:\n&quot;
<span class="lineNum">    4838 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;repeat=@Y[COUNT]@D\n&quot;
<span class="lineNum">    4839 </span>            : &quot;      Run the tests repeatedly; use a negative count to repeat forever.\n&quot;
<span class="lineNum">    4840 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;shuffle@D\n&quot;
<span class="lineNum">    4841 </span>            : &quot;      Randomize tests' orders on every iteration.\n&quot;
<span class="lineNum">    4842 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;random_seed=@Y[NUMBER]@D\n&quot;
<span class="lineNum">    4843 </span>            : &quot;      Random number seed to use for shuffling test orders (between 1 and\n&quot;
<span class="lineNum">    4844 </span>            : &quot;      99999, or 0 to use a seed based on the current time).\n&quot;
<span class="lineNum">    4845 </span>            : &quot;\n&quot;
<span class="lineNum">    4846 </span>            : &quot;Test Output:\n&quot;
<span class="lineNum">    4847 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n&quot;
<span class="lineNum">    4848 </span>            : &quot;      Enable/disable colored output. The default is @Gauto@D.\n&quot;
<span class="lineNum">    4849 </span>            : &quot;  -@G-&quot; GTEST_FLAG_PREFIX_ &quot;print_time=0@D\n&quot;
<span class="lineNum">    4850 </span>            : &quot;      Don't print the elapsed time of each test.\n&quot;
<span class="lineNum">    4851 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;output=xml@Y[@G:@YDIRECTORY_PATH@G&quot;
<span class="lineNum">    4852 </span>            :     GTEST_PATH_SEP_ &quot;@Y|@G:@YFILE_PATH]@D\n&quot;
<span class="lineNum">    4853 </span>            : &quot;      Generate an XML report in the given directory or with the given file\n&quot;
<span class="lineNum">    4854 </span>            : &quot;      name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n&quot;
<span class="lineNum">    4855 </span>            : #if GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    4856 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;stream_result_to=@YHOST@G:@YPORT@D\n&quot;
<span class="lineNum">    4857 </span>            : &quot;      Stream test results to the given server.\n&quot;
<span class="lineNum">    4858 </span>            : #endif  // GTEST_CAN_STREAM_RESULTS_
<span class="lineNum">    4859 </span>            : &quot;\n&quot;
<span class="lineNum">    4860 </span>            : &quot;Assertion Behavior:\n&quot;
<span class="lineNum">    4861 </span>            : #if GTEST_HAS_DEATH_TEST &amp;&amp; !GTEST_OS_WINDOWS
<span class="lineNum">    4862 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n&quot;
<span class="lineNum">    4863 </span>            : &quot;      Set the default death test style.\n&quot;
<span class="lineNum">    4864 </span>            : #endif  // GTEST_HAS_DEATH_TEST &amp;&amp; !GTEST_OS_WINDOWS
<span class="lineNum">    4865 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;break_on_failure@D\n&quot;
<span class="lineNum">    4866 </span>            : &quot;      Turn assertion failures into debugger break-points.\n&quot;
<span class="lineNum">    4867 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;throw_on_failure@D\n&quot;
<span class="lineNum">    4868 </span>            : &quot;      Turn assertion failures into C++ exceptions.\n&quot;
<span class="lineNum">    4869 </span>            : &quot;  @G--&quot; GTEST_FLAG_PREFIX_ &quot;catch_exceptions=0@D\n&quot;
<span class="lineNum">    4870 </span>            : &quot;      Do not report exceptions as test failures. Instead, allow them\n&quot;
<span class="lineNum">    4871 </span>            : &quot;      to crash the program or throw a pop-up (on Windows).\n&quot;
<span class="lineNum">    4872 </span>            : &quot;\n&quot;
<span class="lineNum">    4873 </span>            : &quot;Except for @G--&quot; GTEST_FLAG_PREFIX_ &quot;list_tests@D, you can alternatively set &quot;
<span class="lineNum">    4874 </span>            :     &quot;the corresponding\n&quot;
<span class="lineNum">    4875 </span>            : &quot;environment variable of a flag (all letters in upper-case). For example, to\n&quot;
<span class="lineNum">    4876 </span>            : &quot;disable colored text output, you can either specify @G--&quot; GTEST_FLAG_PREFIX_
<span class="lineNum">    4877 </span>            :     &quot;color=no@D or set\n&quot;
<span class="lineNum">    4878 </span>            : &quot;the @G&quot; GTEST_FLAG_PREFIX_UPPER_ &quot;COLOR@D environment variable to @Gno@D.\n&quot;
<span class="lineNum">    4879 </span>            : &quot;\n&quot;
<span class="lineNum">    4880 </span>            : &quot;For more information, please read the &quot; GTEST_NAME_ &quot; documentation at\n&quot;
<span class="lineNum">    4881 </span>            : &quot;@G&quot; GTEST_PROJECT_URL_ &quot;@D. If you find a bug in &quot; GTEST_NAME_ &quot;\n&quot;
<span class="lineNum">    4882 </span>            : &quot;(not one in your own code or tests), please report it to\n&quot;
<span class="lineNum">    4883 </span>            : &quot;@G&lt;&quot; GTEST_DEV_EMAIL_ &quot;&gt;@D.\n&quot;;
<span class="lineNum">    4884 </span>            : 
<span class="lineNum">    4885 </span>            : // Parses the command line for Google Test flags, without initializing
<span class="lineNum">    4886 </span>            : // other parts of Google Test.  The type parameter CharType can be
<a name="4887"><span class="lineNum">    4887 </span>            : // instantiated to either char or wchar_t.</a>
<span class="lineNum">    4888 </span>            : template &lt;typename CharType&gt;
<span class="lineNum">    4889 </span><span class="lineNoCov">          0 : void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {</span>
<span class="lineNum">    4890 </span><span class="lineNoCov">          0 :   for (int i = 1; i &lt; *argc; i++) {</span>
<span class="lineNum">    4891 </span><span class="lineNoCov">          0 :     const std::string arg_string = StreamableToString(argv[i]);</span>
<span class="lineNum">    4892 </span><span class="lineNoCov">          0 :     const char* const arg = arg_string.c_str();</span>
<span class="lineNum">    4893 </span>            : 
<span class="lineNum">    4894 </span>            :     using internal::ParseBoolFlag;
<span class="lineNum">    4895 </span>            :     using internal::ParseInt32Flag;
<span class="lineNum">    4896 </span>            :     using internal::ParseStringFlag;
<span class="lineNum">    4897 </span>            : 
<span class="lineNum">    4898 </span>            :     // Do we see a Google Test flag?
<span class="lineNum">    4899 </span><span class="lineNoCov">          0 :     if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,</span>
<span class="lineNum">    4900 </span>            :                       &amp;GTEST_FLAG(also_run_disabled_tests)) ||
<span class="lineNum">    4901 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kBreakOnFailureFlag,</span>
<span class="lineNum">    4902 </span>            :                       &amp;GTEST_FLAG(break_on_failure)) ||
<span class="lineNum">    4903 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kCatchExceptionsFlag,</span>
<span class="lineNum">    4904 </span>            :                       &amp;GTEST_FLAG(catch_exceptions)) ||
<span class="lineNum">    4905 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kColorFlag, &amp;GTEST_FLAG(color)) ||</span>
<span class="lineNum">    4906 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kDeathTestStyleFlag,</span>
<span class="lineNum">    4907 </span>            :                         &amp;GTEST_FLAG(death_test_style)) ||
<span class="lineNum">    4908 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kDeathTestUseFork,</span>
<span class="lineNum">    4909 </span>            :                       &amp;GTEST_FLAG(death_test_use_fork)) ||
<span class="lineNum">    4910 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kFilterFlag, &amp;GTEST_FLAG(filter)) ||</span>
<span class="lineNum">    4911 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kInternalRunDeathTestFlag,</span>
<span class="lineNum">    4912 </span>            :                         &amp;GTEST_FLAG(internal_run_death_test)) ||
<span class="lineNum">    4913 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kListTestsFlag, &amp;GTEST_FLAG(list_tests)) ||</span>
<span class="lineNum">    4914 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kOutputFlag, &amp;GTEST_FLAG(output)) ||</span>
<span class="lineNum">    4915 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kPrintTimeFlag, &amp;GTEST_FLAG(print_time)) ||</span>
<span class="lineNum">    4916 </span><span class="lineNoCov">          0 :         ParseInt32Flag(arg, kRandomSeedFlag, &amp;GTEST_FLAG(random_seed)) ||</span>
<span class="lineNum">    4917 </span><span class="lineNoCov">          0 :         ParseInt32Flag(arg, kRepeatFlag, &amp;GTEST_FLAG(repeat)) ||</span>
<span class="lineNum">    4918 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kShuffleFlag, &amp;GTEST_FLAG(shuffle)) ||</span>
<span class="lineNum">    4919 </span><span class="lineNoCov">          0 :         ParseInt32Flag(arg, kStackTraceDepthFlag,</span>
<span class="lineNum">    4920 </span>            :                        &amp;GTEST_FLAG(stack_trace_depth)) ||
<span class="lineNum">    4921 </span><span class="lineNoCov">          0 :         ParseStringFlag(arg, kStreamResultToFlag,</span>
<span class="lineNum">    4922 </span>            :                         &amp;GTEST_FLAG(stream_result_to)) ||
<span class="lineNum">    4923 </span><span class="lineNoCov">          0 :         ParseBoolFlag(arg, kThrowOnFailureFlag,</span>
<span class="lineNum">    4924 </span>            :                       &amp;GTEST_FLAG(throw_on_failure))
<span class="lineNum">    4925 </span>            :         ) {
<span class="lineNum">    4926 </span>            :       // Yes.  Shift the remainder of the argv list left by one.  Note
<span class="lineNum">    4927 </span>            :       // that argv has (*argc + 1) elements, the last one always being
<span class="lineNum">    4928 </span>            :       // NULL.  The following loop moves the trailing NULL element as
<span class="lineNum">    4929 </span>            :       // well.
<span class="lineNum">    4930 </span><span class="lineNoCov">          0 :       for (int j = i; j != *argc; j++) {</span>
<span class="lineNum">    4931 </span><span class="lineNoCov">          0 :         argv[j] = argv[j + 1];</span>
<span class="lineNum">    4932 </span>            :       }
<span class="lineNum">    4933 </span>            : 
<span class="lineNum">    4934 </span>            :       // Decrements the argument count.
<span class="lineNum">    4935 </span><span class="lineNoCov">          0 :       (*argc)--;</span>
<span class="lineNum">    4936 </span>            : 
<span class="lineNum">    4937 </span>            :       // We also need to decrement the iterator as we just removed
<span class="lineNum">    4938 </span>            :       // an element.
<span class="lineNum">    4939 </span><span class="lineNoCov">          0 :       i--;</span>
<span class="lineNum">    4940 </span><span class="lineNoCov">          0 :     } else if (arg_string == &quot;--help&quot; || arg_string == &quot;-h&quot; ||</span>
<span class="lineNum">    4941 </span><span class="lineNoCov">          0 :                arg_string == &quot;-?&quot; || arg_string == &quot;/?&quot; ||</span>
<span class="lineNum">    4942 </span><span class="lineNoCov">          0 :                HasGoogleTestFlagPrefix(arg)) {</span>
<span class="lineNum">    4943 </span>            :       // Both help flag and unrecognized Google Test flags (excluding
<span class="lineNum">    4944 </span>            :       // internal ones) trigger help display.
<span class="lineNum">    4945 </span><span class="lineNoCov">          0 :       g_help_flag = true;</span>
<span class="lineNum">    4946 </span>            :     }
<span class="lineNum">    4947 </span>            :   }
<span class="lineNum">    4948 </span>            : 
<span class="lineNum">    4949 </span><span class="lineNoCov">          0 :   if (g_help_flag) {</span>
<span class="lineNum">    4950 </span>            :     // We print the help here instead of in RUN_ALL_TESTS(), as the
<span class="lineNum">    4951 </span>            :     // latter may not be called at all if the user is using Google
<span class="lineNum">    4952 </span>            :     // Test with another testing framework.
<span class="lineNum">    4953 </span><span class="lineNoCov">          0 :     PrintColorEncoded(kColorEncodedHelpMessage);</span>
<span class="lineNum">    4954 </span>            :   }
<span class="lineNum">    4955 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4956 </span>            : 
<a name="4957"><span class="lineNum">    4957 </span>            : // Parses the command line for Google Test flags, without initializing</a>
<span class="lineNum">    4958 </span>            : // other parts of Google Test.
<span class="lineNum">    4959 </span><span class="lineNoCov">          0 : void ParseGoogleTestFlagsOnly(int* argc, char** argv) {</span>
<a name="4960"><span class="lineNum">    4960 </span><span class="lineNoCov">          0 :   ParseGoogleTestFlagsOnlyImpl(argc, argv);</span></a>
<span class="lineNum">    4961 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4962 </span><span class="lineNoCov">          0 : void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {</span>
<span class="lineNum">    4963 </span><span class="lineNoCov">          0 :   ParseGoogleTestFlagsOnlyImpl(argc, argv);</span>
<span class="lineNum">    4964 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    4965 </span>            : 
<span class="lineNum">    4966 </span>            : // The internal implementation of InitGoogleTest().
<span class="lineNum">    4967 </span>            : //
<span class="lineNum">    4968 </span>            : // The type parameter CharType can be instantiated to either char or
<a name="4969"><span class="lineNum">    4969 </span>            : // wchar_t.</a>
<span class="lineNum">    4970 </span>            : template &lt;typename CharType&gt;
<span class="lineNum">    4971 </span><span class="lineNoCov">          0 : void InitGoogleTestImpl(int* argc, CharType** argv) {</span>
<span class="lineNum">    4972 </span><span class="lineNoCov">          0 :   g_init_gtest_count++;</span>
<span class="lineNum">    4973 </span>            : 
<span class="lineNum">    4974 </span>            :   // We don't want to run the initialization code twice.
<span class="lineNum">    4975 </span><span class="lineNoCov">          0 :   if (g_init_gtest_count != 1) return;</span>
<span class="lineNum">    4976 </span>            : 
<span class="lineNum">    4977 </span><span class="lineNoCov">          0 :   if (*argc &lt;= 0) return;</span>
<span class="lineNum">    4978 </span>            : 
<span class="lineNum">    4979 </span><span class="lineNoCov">          0 :   internal::g_executable_path = internal::StreamableToString(argv[0]);</span>
<span class="lineNum">    4980 </span>            : 
<span class="lineNum">    4981 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">    4982 </span>            : 
<span class="lineNum">    4983 </span><span class="lineNoCov">          0 :   g_argvs.clear();</span>
<span class="lineNum">    4984 </span><span class="lineNoCov">          0 :   for (int i = 0; i != *argc; i++) {</span>
<span class="lineNum">    4985 </span><span class="lineNoCov">          0 :     g_argvs.push_back(StreamableToString(argv[i]));</span>
<span class="lineNum">    4986 </span>            :   }
<span class="lineNum">    4987 </span>            : 
<span class="lineNum">    4988 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">    4989 </span>            : 
<span class="lineNum">    4990 </span><span class="lineNoCov">          0 :   ParseGoogleTestFlagsOnly(argc, argv);</span>
<span class="lineNum">    4991 </span><span class="lineNoCov">          0 :   GetUnitTestImpl()-&gt;PostFlagParsingInit();</span>
<span class="lineNum">    4992 </span>            : }
<span class="lineNum">    4993 </span>            : 
<span class="lineNum">    4994 </span>            : }  // namespace internal
<span class="lineNum">    4995 </span>            : 
<span class="lineNum">    4996 </span>            : // Initializes Google Test.  This must be called before calling
<span class="lineNum">    4997 </span>            : // RUN_ALL_TESTS().  In particular, it parses a command line for the
<span class="lineNum">    4998 </span>            : // flags that Google Test recognizes.  Whenever a Google Test flag is
<span class="lineNum">    4999 </span>            : // seen, it is removed from argv, and *argc is decremented.
<span class="lineNum">    5000 </span>            : //
<span class="lineNum">    5001 </span>            : // No value is returned.  Instead, the Google Test flag variables are
<span class="lineNum">    5002 </span>            : // updated.
<a name="5003"><span class="lineNum">    5003 </span>            : //</a>
<span class="lineNum">    5004 </span>            : // Calling the function for the second time has no user-visible effect.
<span class="lineNum">    5005 </span><span class="lineNoCov">          0 : void InitGoogleTest(int* argc, char** argv) {</span>
<span class="lineNum">    5006 </span><span class="lineNoCov">          0 :   internal::InitGoogleTestImpl(argc, argv);</span>
<span class="lineNum">    5007 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    5008 </span>            : 
<a name="5009"><span class="lineNum">    5009 </span>            : // This overloaded version can be used in Windows programs compiled in</a>
<span class="lineNum">    5010 </span>            : // UNICODE mode.
<span class="lineNum">    5011 </span><span class="lineNoCov">          0 : void InitGoogleTest(int* argc, wchar_t** argv) {</span>
<span class="lineNum">    5012 </span><span class="lineNoCov">          0 :   internal::InitGoogleTestImpl(argc, argv);</span>
<span class="lineNum">    5013 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    5014 </span>            : 
<span class="lineNum">    5015 </span>            : }  // namespace testing
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
